Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
Top SWE
Bradley Allen
NeetCodeIO
codingMohan
Huifeng Guan
Programming Live with Larry
CodeInsanity
Solve more problems to master this pattern