Watch tutorials and explanations by expert teachers that walk through solving this problem.
Math Geeks
Code Thoughts
FMVP
kgstrivers
LeetcodeDailyGrind
LetsCode
ELeetCoder
code7you
The learning rabidness
Solve more problems to master this pattern