NeetCode #804LC-135HardGreedyNC 250
← Back to All Problems#804 · #135 · Candy(分发糖果)
📌 Problem Statement & Constraints
There are
n children in a line, each with a ratings[i]. Give each child at least one candy; any child with a higher rating than an immediate neighbour must receive more candies than that neighbour. Return the minimum total candies. Constraints: 1 <= n <= 2 * 10^4, 0 <= ratings[i] <= 2 * 10^4.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!