Candy - Two Pass - O(n) Space
In this video, we solve the Candy problem with a two-pass algorithm. You’ll see how to allocate candies based on ratings by scanning from left to right and right to left, ensuring all rules are satisfied.
In this video, we solve the Candy problem with a two-pass algorithm. You’ll see how to allocate candies based on ratings by scanning from left to right and right to left, ensuring all rules are satisfied.