Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
NeetCodeIO
CodeCake
Bayu Aji
Algorithms Casts
Programming Live with Larry
Code Coder
Solve more problems to master this pattern