Two Pointers
This kind of problem is pretty interesting. Watch the video.
Problems
- https://dmoj.ca/problem/aac1p4 (NOPE, too slow with 2 pointer solution)
What about the subarray sum? The CP Handbook shows two pointer way, but I am pretty sure it doesn’t work if the array is unsorted.