Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
stoney codes
Sahil & Sarra
CrioDo
Competitive Somya
Programming Live with Larry
Anytime4u
Sleepy Cracker
Solve more problems to master this pattern