Link: https://leetcode.com/problems/candy/
Solution:
Intuition
Very nice problem utilizing a greedy forwards/backwards scan pattern. I don’t really have an intuition for this problem other than recognizing that the starting point is giving every child one candy and then iteratively meeting the constraints, first in a forward pass and then in a backwards pass (being careful not to ruin the work done on the forward pass).
Implementation
Visual