Watch tutorials and explanations by expert teachers that walk through solving this problem.
Ben Dickey
NeetCodeIO
coder4life
Hanu
AnshulOnTech
Endeavour Monk
Scott Hacks Code
Alpha-Code
Solve more problems to master this pattern