Hello guys, asked 01 Nov '17, 00:07

By seeing your post i have gone through problem maxi...i have solved it in O(n^2).But some comments claimed that they solved this in O(n).I can not figure out how they did it in O(n) but i there is solution in O(n) and it takes 0.0 s,mine takes 0.13 s.But for O(n^2) its dynamic programming if u see it carefully. Hope this helps. answered 01 Nov '17, 13:04
Thanks for the reply. It would be great if you can give a link to your code!
(01 Nov '17, 13:12)
https://ideone.com/eyTMjd if something is not clear to you in my code u can ask and Welcome :)
(01 Nov '17, 13:16)
1
Thank you :)
(01 Nov '17, 16:54)
Because its asymptotic complexity not exact complexity :). Inner loops upper bound keeps up decrements by 1 each time you run the loop. So it n only at first iteration there after it will keep decrements and reduce the time.
(01 Nov '17, 17:07)

@likecs as you have set this question any tips would be much appreciated!