Reverse Print
JavaScript
Easy
5 views
Problem Description
You got n numbers in an array. Print them in reverse order. Simple thing, but do it clean.
Input Format
One line: n then n integers.
Output Format
One line: reversed numbers space separated.
Official Solution
const fs=require('fs');const p=fs.readFileSync(0,'utf8').trim().split(/\\s+/);if(!p[0])process.exit(0);let i=0;const n=Number(p[i++]);let arr=[];for(let j=0;j<n;j++)arr.push(p[i++]);arr.reverse();process.stdout.write(arr.join(' '));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!