Answer to Question #326651 in HTML/JavaScript Web Application for Bylapati suresh kumar

Question #326651

"use strict";


process.stdin.resume();

process.stdin.setEncoding("utf-8");


let inputString = "";

let currentLine = 0;


process.stdin.on("data", (inputStdin) => {

inputString += inputStdin;

});


process.stdin.on("end", (_) => {

inputString = inputString

.trim()

.split("\n")

.map((str) => str.trim());

main();

});


function readLine() {

return inputString[currentLine++];

}


function main() {

let myArray = JSON.parse(readLine());


/* Please do not modify anything above this line */


/* Write your code here and log the output */

let min = myArray[0], result = undefined, index = 0;

while (myArray.length) {

myArray.map((e, i)=> {

if (e < min) min = e;

index = i

})

if (min % 3 === 0 && min % 2 === 0) {

result = min;

break

}

myArray.splice(index, 1);

min = myArray[0];

}


console.log(result)


}


other logic is solutiion


1
Expert's answer
2022-04-10T17:45:20-0400
"use strict";


process.stdin.resume();
process.stdin.setEncoding("utf-8");


let inputString = "";
let currentLine = 0;


process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});


process.stdin.on("end", (_) => {
inputString = inputString
.trim()
.split("\n")
.map((str) => str.trim());
main();
});


function readLine() {
return inputString[currentLine++];
}


function main() {
let myArray = JSON.parse(readLine());
/* Please do not modify anything above this line */
/* Write your code here and log the output */
let min = myArray[0];
for(let i =0; i< myArray.length; i++){


 if (myArray[i] % 3 === 0 && myArray[i] % 2 === 0){


    if(min % 3 === 0 && min % 2 === 0){


       if(min > myArray[i]){
          min = myArray[i];
        }


       else{
        min = myArray[i];
       }
    } 
  }
}
console.log(min);
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS