Hi, I solved this problem using following way. First create a cumulative sum array. Then use O(n^2) bruteforce for the result. Are there any other solutions to solve this problem?
Hrm. We need to tighten the limits.
The intended solution is using the two pointers ( Actually 3 pointers in this case - For every number, we maintain a start of range, end of range ). As we move the number forward, the start and end can only move forward.
Anshuman Singh Can you please elaborate the explanation. I am unable to get it. What do you mean by the start and end can only move forward? I will be glad if you can give an example.