Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
Inside code
Nick White
Techdose
Nikhil Lohia
Timothy H Chang
Greg Hogg
Algorithms Made Easy
Persistent Programmer
Solve more problems to master this pattern