Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCodeIO
Algorithms for Big Bucks
Timothy H Chang
Sonali Gupta
Shuo Yan
Programming Live with Larry
comicfans44
Solve more problems to master this pattern