Hacker rank: Multi line input
Reading input from hacker rank
JavaScript
function processData(input) {
//Enter your code here
lines = input.split("\n");
var totalItems = lines[0].split(" ").map(Number)[0],
allergyItem = lines[0].split(" ").map(Number)[1],
itemCostArray = lines[1].split(" ").map(Number),
charged = parseInt(lines[2]);
console.log(charged)
print(charged)
}
processData("4 1\n3 10 2 9\n 7")
/*
Input Format
The first line contains two space-separated integers denoting the respective values of (the number of items ordered) and (the -based index of the item that Anna did not eat).
The second line contains space-separated integers where each integer denotes the cost, , of item (where ).
The third line contains an integer, , denoting the amount of money that Brian charged Anna for her share of the bill.
*/