Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
Greg Hogg
NeetCodeIO
Ayush Rao
JUST CODE
Programming Live with Larry
Code Ninja
Coder on A Farm
Solve more problems to master this pattern