Watch tutorials and explanations by expert teachers that walk through solving this problem.
CyCode
jin's tutorial
Athar Mohd
Programming Live with Larry
Alpha-Code
LetsCode
Fearless Learner
LeetCode The Hard Way
Solve more problems to master this pattern