Watch tutorials and explanations by expert teachers that walk through solving this problem.
stoney codes
Sahil & Sarra
NeetCode
take U forward
AlgoMonster
Back To Back SWE
Solve more problems to master this pattern