Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCodeIO
SF
Mike the Coder
Programming Live with Larry
Hunter Macias
One Code Man
IB
Code Monger
Solve more problems to master this pattern