We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi guys, this was my first chalange in hackerrank and I cannot understand the results, could you help me?
That's my code:
process.stdin.resume();process.stdin.setEncoding('ascii');varinput_stdin="";varinput_stdin_array="";varinput_currentline=0;process.stdin.on('data',function(data){input_stdin+=data;});process.stdin.on('end',function(){input_stdin_array=input_stdin.split("\n");main();});functionreadLine(){returninput_stdin_array[input_currentline++];}/////////////// ignore above this line ////////////////////functionmain(){varn=parseInt(readLine());file=readLine().split(' ');file=file.map(Number);console.log((functionrecourse(n,arr){if(arr.length<=0)returnn;returnrecourse(++n,arr.slice(arr.shift()));})(0,file));// Print the number of arrays defined in 'file' to STDOUT.}
I've only made the console.log part, the rest was the chalange boilerplate for JS.
Well, this works for me and a lot of test cases, the #4 seens to be wrong, but I've reproduce here in my computer and get the right result (1001)!
Some other tests have been aborted... Someone could point my error or explain why this code fail the tests?
Thanks!!
Renan
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Recover the Arrays
You are viewing a single comment's thread. Return to all comments →
Hi guys, this was my first chalange in hackerrank and I cannot understand the results, could you help me? That's my code:
I've only made the console.log part, the rest was the chalange boilerplate for JS.
Well, this works for me and a lot of test cases, the #4 seens to be wrong, but I've reproduce here in my computer and get the right result (1001)! Some other tests have been aborted... Someone could point my error or explain why this code fail the tests?
Thanks!! Renan