Link to leetcode problem: https://leetcode.com/problems/container-with-most-water/?envType=study-plan-v2&envId=top-interview-150
if we consider this solution: https://leetcode.com/problems/container-with-most-water/solutions/5022358/video-two-pointer-solution/
I'm kind of confused why this specific two-pointer solution is also considered a greedy approach because I thought for greedy approaches, we have to find the optimal solution locally 'so that it never goes back and reverses direction', but in the solution, we always have to compare with our previous area.
Any tips on how to intuitively know that we should use greedy (as opposed to DP for example) for this problem as well because in general greedy may not work for all optimization problems?