Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCodeIO
Everyday Data Science
NeetCode
Nick White
BarikZone
Frederik Müller
Solve more problems to master this pattern