Skip to content

Commit bfeb895

Browse files
committedDec 15, 2021
solves kids with the greatest numberof candies
1 parent 45e55ef commit bfeb895

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed
 

‎README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@
361361
| 1413 | [Minimum Value To Get Positive Step By Step Sum](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum) | [![Java](assets/java.png)](src/MinimumValueToGetPositiveStepByStepSum.java) | |
362362
| 1417 | [Reformat The String](https://leetcode.com/problems/reformat-the-string) | [![Java](assets/java.png)](src/ReformatTheString.java) | |
363363
| 1422 | [Maximum Score After Splitting A String](https://leetcode.com/problems/maximum-score-after-splitting-a-string) | [![Java](assets/java.png)](src/MaximumScoreAfterSplittingAString.java) | |
364-
| 1426 | [Counting Elements](https://leetcode.com/problems/counting-elements) | | |
365-
| 1427 | [Performing String Shifts](https://leetcode.com/problems/perform-string-shifts) | | |
366-
| 1431 | [Kids With The Greatest Number Of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies) | | |
364+
| 1426 | 🔒 [Counting Elements](https://leetcode.com/problems/counting-elements) | | |
365+
| 1427 | 🔒 [Performing String Shifts](https://leetcode.com/problems/perform-string-shifts) | | |
366+
| 1431 | [Kids With The Greatest Number Of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies) | [![Java](assets/java.png)](src/KidsWithTheGreatestNumberOfCandies.java) | |
367367
| 1436 | [Destination City](https://leetcode.com/problems/destination-city) | | |
368368
| 1441 | [Build An Array With Stack Operation](https://leetcode.com/problems/build-an-array-with-stack-operations) | | |
369369
| 1446 | [Consecutive Characters](https://leetcode.com/problems/consecutive-characters) | | |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.util.ArrayList;
2+
import java.util.Arrays;
3+
import java.util.List;
4+
5+
public class KidsWithTheGreatestNumberOfCandies {
6+
public List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
7+
final List<Boolean> result = new ArrayList<>();
8+
final int maxCandies = Arrays.stream(candies).max().getAsInt();
9+
for (int person : candies) {
10+
result.add(person + extraCandies >= maxCandies);
11+
}
12+
return result;
13+
}
14+
}

0 commit comments

Comments
 (0)
Please sign in to comment.