Soal
SebelumnyaBerikutnya
00:00

32. Candy

SulitArrayAmazonGoogle

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

Contoh 1:

Input: ratings = [1,0,2]
Output: 5

Contoh 2:

Input: ratings = [1,2,2]
Output: 4

Batasan:

  • 1 <= ratings.length <= 2 * 10^4
Mode kode inti
● Tersimpan otomatisBaris 1, kolom 1