File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 294
294
| 1085 | π [ Sum of Digits in Minimum Number] ( https://leetcode.com/problems/sum-of-digits-in-the-minimum-number ) | | |
295
295
| 1086 | π [ High Five] ( https://leetcode.com/problems/high-five ) | | |
296
296
| 1089 | [ Duplicate Zeroes] ( https://leetcode.com/problems/duplicate-zeros ) | [ ![ Java] ( assets/java.png )] ( src/DuplicateZeros.java ) | |
297
- | 1099 | [ Two Sum Less Than K] ( https://leetcode.com/problems/two-sum-less-than-k ) | | |
298
- | 1103 | [ Distribute Candies to People] ( https://leetcode.com/problems/distribute-candies-to-people ) | | |
297
+ | 1099 | π [ Two Sum Less Than K] ( https://leetcode.com/problems/two-sum-less-than-k ) | | |
298
+ | 1103 | [ Distribute Candies to People] ( https://leetcode.com/problems/distribute-candies-to-people ) | [ ![ Java ] ( assets/java.png )] ( src/DistributeCandiesToPeople.java ) | |
299
299
| 1108 | [ Defanging an IP Address] ( https://leetcode.com/problems/defanging-an-ip-address ) | | |
300
300
| 1118 | [ Number of Days in a Month] ( https://leetcode.com/problems/number-of-days-in-a-month ) | | |
301
301
| 1119 | [ Remove Vowels From String] ( https://leetcode.com/problems/remove-vowels-from-a-string ) | | |
Original file line number Diff line number Diff line change
1
+ public class DistributeCandiesToPeople {
2
+ public int [] distributeCandies (int candies , int people ) {
3
+ final int [] result = new int [people ];
4
+ for (int i = 0 , k = 1 ; candies > 0 ; k ++, i = (i + 1 ) % people ) {
5
+ result [i ] += Math .min (candies , k );
6
+ candies -= Math .min (candies , k );
7
+ }
8
+ return result ;
9
+ }
10
+ }
You canβt perform that action at this time.
0 commit comments