The code i’ve written more basic approach than kadane’s algo is O(n^2). Still i’m getting the error time limit exceeded. Why? I did go through kadane’s algo but I just wanted to implement more basic method.
Time limit exceeding error
hello @vaani787
value of n can be upto 10^5 . so in worst case O(N^2) algorithm will perform 10^10 operations which is too slow to pass the test case.
optimise it using kadane
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.