Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCodeIO
Sai Anish Malla
Techdose
Timothy H Chang
Programming Live with Larry
Hua Hua
Solve more problems to master this pattern