Watch tutorials and explanations by expert teachers that walk through solving this problem.
Sahil & Sarra
NeetCode
NeetCodeIO
take U forward
Coding Interviews
Fraz
Solve more problems to master this pattern