Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
ThePrimeTime
NeetCodeIO
Bradley Allen
Programming Live with Larry
Daily Dose of Leetcode
Solve more problems to master this pattern