Watch tutorials and explanations by expert teachers that walk through solving this problem.
Cracking FAANG
Timothy H Chang
NeetCodeIO
Algorithms Made Easy
CodingForBeginners
Coding Answerz
Solve more problems to master this pattern