Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
Tushar Roy - Coding Made Simple
NeetCodeIO
The Code Skool
Coders Camp
Jeevan Kumar - Crackify
Solve more problems to master this pattern