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