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