Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCodeIO
Prakhar Agrawal
codingMohan
Ayush Rao
Bayu Aji
Coding Samurai's
Optimization
Solve more problems to master this pattern