The Question
CodingMinimum Candy Distribution
Given an array of integers representing ratings of $n$ children in a line, determine the minimum number of candies required to satisfy two conditions: 1) Each child must receive at least one candy. 2) A child with a higher rating than an adjacent neighbor must receive more candies than that neighbor. Implement an efficient solution and discuss its time and space complexity.
Java
Greedy
Array
March 30, 2026