FastPrepMinimum Candies by Rating
Problems/Minimum Candies by Rating

Minimum Candies by Rating

Citadel logoCitadel● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Citadel phone screen. The report names the standard candy problem with ratings of neighbors. It leaves out the function interface and the numeric limits. Our version is about 98% the same as the reported question.

There are n children standing in a line. The integer array ratings gives each child's rating.

Give candies to the children subject to these rules:

  • Every child receives at least one candy.
  • If a child has a higher rating than an adjacent child, the higher-rated child must receive more candies.

Return the minimum total number of candies required.

Function

minimumCandies(ratings: int[]) → long

Examples

Example 1

ratings = [1,0,2]return = 5

The minimum valid allocation is [2,1,2], whose total is 5.

Example 2

ratings = [1,2,2]return = 4

The allocation [1,2,1] is valid. Equal ratings do not require different candy counts.

Constraints

  • 1 <= ratings.length <= 200000
  • -10^9 <= ratings[i] <= 10^9
  • The answer fits in a signed 64-bit integer.

More Citadel Phone Screen questions

  • Merge Price-Delta FeedsPHONE SCREEN · Seen Dec 2026
  • Speed Up a Slow FunctionOA · PHONE SCREEN · Seen Nov 2026
  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
  • Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
  • Currency Arbitrage CyclePHONE SCREEN · Seen Sep 2026
  • Order Book with Cancel by Order IDPHONE SCREEN · Seen Sep 2026
  • Smart Queue of Latest PricesPHONE SCREEN · Seen Sep 2026
  • Reconcile Unmatched Trades with Timestamp TolerancePHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Starlink Beam PlannerSpaceX · OA · PHONE SCREENSpaceX interview questions
  • Greedy Person-Cake Matching DistanceSnowflake · PHONE SCREENSnowflake interview questions
  • Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
  • Maximize Fish over Limited HoursByteDance · PHONE SCREENByteDance interview questions
  • Maximize Adjacent Difference With One ReversalAmazon · PHONE SCREEN
  • IPOTekion · PHONE SCREENTekion interview questions
  • Text JustificationUber · PHONE SCREENUber interview questions
  • Find GPU Capacity and Drain a NodeTogether AI · PHONE SCREEN
  • IPOInMobi · PHONE SCREENInMobi interview questions
  • Lexicographically Smallest Array with K-Limited Right MovesGoogle · PHONE SCREENGoogle interview questions

Citadel interview experiences

  • Citadel Securities Quant Researcher Intern Loop: 1 Experience
  • Citadel Securities Research Engineer Interview: 1 Experience
  • Citadel Securities SWE Intern First Round: 2 Experiences
  • Citadel Securities Experienced SWE Interviews: 1 Experience
  • Citadel SWE Intern Later Rounds and Superday: 13 Experiences
  • Citadel SWE Intern First-Round Questions: 20 Experiences
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public long minimumCandies(int[] ratings) {
        // write your code here
    }
}
Checking account…