Skip to content

Commit d9f48fb

Browse files
committed
Create README - LeetHub
1 parent 2679598 commit d9f48fb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

0135-candy/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/candy/?envType=daily-question&envId=2025-06-02">135. Candy</a></h2><h3>Hard</h3><hr><p>There are <code>n</code> children standing in a line. Each child is assigned a rating value given in the integer array <code>ratings</code>.</p>
2+
3+
<p>You are giving candies to these children subjected to the following requirements:</p>
4+
5+
<ul>
6+
<li>Each child must have at least one candy.</li>
7+
<li>Children with a higher rating get more candies than their neighbors.</li>
8+
</ul>
9+
10+
<p>Return <em>the minimum number of candies you need to have to distribute the candies to the children</em>.</p>
11+
12+
<p>&nbsp;</p>
13+
<p><strong class="example">Example 1:</strong></p>
14+
15+
<pre>
16+
<strong>Input:</strong> ratings = [1,0,2]
17+
<strong>Output:</strong> 5
18+
<strong>Explanation:</strong> You can allocate to the first, second and third child with 2, 1, 2 candies respectively.
19+
</pre>
20+
21+
<p><strong class="example">Example 2:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> ratings = [1,2,2]
25+
<strong>Output:</strong> 4
26+
<strong>Explanation:</strong> You can allocate to the first, second and third child with 1, 2, 1 candies respectively.
27+
The third child gets 1 candy because it satisfies the above two conditions.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>n == ratings.length</code></li>
35+
<li><code>1 &lt;= n &lt;= 2 * 10<sup>4</sup></code></li>
36+
<li><code>0 &lt;= ratings[i] &lt;= 2 * 10<sup>4</sup></code></li>
37+
</ul>

0 commit comments

Comments
 (0)