Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCodeIO
One Code Man
Programming Live with Larry
Elite Code
Think-Twice-Code-Once
Solve more problems to master this pattern