Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
NeetCodeIO
stoney codes
Sahil & Sarra
Dave Burji
Striver
Green Code
Solve more problems to master this pattern