Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCodeIO
Algorithms Made Easy
Nick White
codestorywithMIK
Aryan Mittal
Techdose
Sai Anish Malla
Solve more problems to master this pattern