+ 1
Can anyone give me optimised code in time complexity of O(n) ?
https://www.codechef.com/IARCSJUD/problems/LONGPALI Visit above url for problem specification. Below is my code's url https://code.sololearn.com/cLBSXAs9ImJ7/?ref=app Although my code has passed all the test cases and it is accepted by the online judge but it is in O(n^2) complexity and i want it in O(n). If anyone can provide more optimised code it will be helpful. 😊
1 ответ
+ 1
I cant visit the website on my phone, so i dont know what you code does.
How ever, you should try 1) to avoid using nested for loop, if that's not possible 2) try to skip checking all values which can be predicted to be useless