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.
- Prepare
- Algorithms
- Bit Manipulation
- Iterate It
- Discussions
Iterate It
Iterate It
Sort by
recency
|
13 Discussions
|
Please Login in order to post a comment
Here is Iterate It problem solution in Python Java C++ and c programming - https://programs.programmingoneonone.com/2021/07/hackerrank-iterate-it-problem-solution.html
Mathematically it is easy to see that the program will always terminate, because after each iteration, the maximum number from the original list will never show up in the next list and the max keeps decreasing. The challenge, of course, is to figure out the exact number of steps it will take to terminate within the bounds of limited computation resources.
I've solved the psuedocode , but the thing is I am not able to find the solution if the loop never ends {i.e., -1 . Its a bit tricky}.
If any one can find the solution please do reply back.
Could anyone please tell me what's the problem statement means actually?
OK, so I get the looping through twice, once for X and once for Y. I am passing SOME test cases, but not all of them. In that the call is aborted any time where the process never terminates. Understandable, but what is it I'm to be looking for that indicates something will NOT terminate?