Answer to Question #271069 in HTML/JavaScript Web Application for prime

Question #271069

Square at Alternate Indices


https://drive.google.com/drive/folders/1vXgw6-3c1Dq3ZuCh_NgesMayQmSLC_wb?usp=sharing


Please fill the code in "write your code here"


They were just sample outputs. There are other test cases too which should be passed


1
Expert's answer
2021-11-26T17:43:17-0500
    "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++];
    }


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


    function main() {
      const myArray = JSON.parse(readLine());
      let arr = [];
      for (let i = 0; i < myArray.length; i++) {
        arr.push(myArray[i]*myArray[i]);
      }
      return arr;
      
    }

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