Watch tutorials and explanations by expert teachers that walk through solving this problem.
CS Dojo
take U forward
NeetCode
Nick White
NeetCodeIO
Nikhil Lohia
Keep On Coding
Greg Hogg
Solve more problems to master this pattern