Skip to content
Advertisement

Time limit exceeded in hackerearth exercise

I’m trying to solve this exercise in HackerEarth. But I have an error of time limit exceeded. This is the code that I wrote :

JavaScript

Advertisement

Answer

Your solution is a little bit slow because of the bad implementation. I rewrote your solution in better implementation with the same logic and time complexity of your solution and get Accepted and none of the test cases exceeded .8 second

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement