Watch tutorials and explanations by expert teachers that walk through solving this problem.
Hua Hua
Fraz
Programming Live with Larry
Ghumman Tech
Code Circle
Decode
CSE Unfiltered
ExtremeProgrammer
Solve more problems to master this pattern