dsa1 min read
Candy [Hard/Medium] — Two-Pass Greedy
Distribute minimum candies so each child with higher rating than neighbors gets more, using left-to-right then right-to-left passes.
Read →
webcoderspeed.com
1276 articles
Distribute minimum candies so each child with higher rating than neighbors gets more, using left-to-right then right-to-left passes.
Find the minimum total moves to make all array elements equal by targeting the median value.
Find the longest nested set S(k) in a permutation array by tracing cycles with visited marking in O(n) time.
Rearrange nums to maximize advantage over B using a greedy strategy: assign the smallest winning card, else discard the smallest.
Generate all unique subsets from an array with duplicates by sorting and skipping repeated elements at each recursion level.