Can anyone tell me what algo should i be following for O(nlogn) complexity? I am getting tle in O(N^2).
Satyaki Chakraborty It is’t working. I got TLE using this method.
u can break loop in O(n^2) for sum>C, this reduces time and even O(n^2) can get accepted mine did.
You can make a cumulative sum array and apply binary search on that.
There exists a O(n) time solution.