This is the canonical two-pointer problem on sorted arrays — the foundation for 3Sum, Container With Most Water, and many other problems.
Enable JavaScript for the full StreamPrep guide.