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.
My code passes two testcases and I believe the logic is right.But for other testcases it gives "terminated due to timeout error". Can you tell what's going wrong ?
The for loop in the saveThePrisoner function is probably taking too long to execute. Notice that my code does not have such a for loop (other than the for loop that has to run all the testcases)
Save the Prisoner!
You are viewing a single comment's thread. Return to all comments →
My code passes two testcases and I believe the logic is right.But for other testcases it gives "terminated due to timeout error". Can you tell what's going wrong ?
The for loop in the saveThePrisoner function is probably taking too long to execute. Notice that my code does not have such a for loop (other than the for loop that has to run all the testcases)
HackerRank solutions.
Ohk ,thats probably right. Thanks
Dude you are a genius! I don't know how you figured out the minus and plus concept
i have same issue. but i know what is actual problem. if i don't shutdown my system wil crashed.
i ran my code using cpp. here in the first if of for loop x should assigned to 0 as x increments after each iteration so that for x==n, x will be 1
java 8 O(1) : return ((s+m-1)%n >0)?(s+m-1)%n:(s+m-1)%n +n ;
it is an circular array method