Watch tutorials and explanations by expert teachers that walk through solving this problem.
Tim Huang
Coding Guys
Roel Van de Paar
chillX
ExtremeProgrammer
AlgoHub
hornclause
The learning rabidness
code7you
Solve more problems to master this pattern