प्रश्न
पिछलाअगला
00:00

32. Candy

कठिनऐरेAmazonGoogle

Give every child at least one candy while higher-rated adjacent children receive more. Return the minimum total.

उदाहरण 1:

इनपुट: ratings = [1,0,2]
आउटपुट: 5

उदाहरण 2:

इनपुट: ratings = [1,2,2]
आउटपुट: 4

सीमाएँ:

  • 1 <= ratings.length <= 2 * 10^4
मुख्य कोड मोड
● अपने आप सहेजा गयापंक्ति 1, कॉलम 1