Watch tutorials and explanations by expert teachers that walk through solving this problem.
Nick White
NeetCodeIO
Timothy H Chang
Algorithms Made Easy
Sai Anish Malla
TKGgames
Aleksandr Zelenin
Solve more problems to master this pattern