Skip to content

Instantly share code, notes, and snippets.

@yashikagarg13
Last active February 23, 2017 14:23
Show Gist options
  • Save yashikagarg13/a5e187088e9c008921fb7b3bce5a538f to your computer and use it in GitHub Desktop.
Save yashikagarg13/a5e187088e9c008921fb7b3bce5a538f to your computer and use it in GitHub Desktop.
Hacker Rank - Algorithms Practise 2
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});
function readLine() {
return input_stdin_array[input_currentline++];
}
/////////////// ignore above this line ////////////////////
function main() {
var n = parseInt(readLine());
arr = readLine().split(' ');
arr = arr.map(Number);
var sum = arr.reduce((s, n) => s+n, 0);
console.log(sum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment