Watch tutorials and explanations by expert teachers that walk through solving this problem.
Ashish Pratap Singh
Striver
take U forward
NeetCode
CodeHelp - by Babbar
Tushar Roy - Coding Made Simple
GeeksforGeeks
Solve more problems to master this pattern