File tree 1 file changed +4
-4
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 39
39
* */
40
40
public class _1103 {
41
41
public static class Solution1 {
42
- public int [] distributeCandies (int candies , int num_people ) {
42
+ public int [] distributeCandies (int candies , int numPeople ) {
43
43
Map <Integer , Integer > map = new HashMap <>();
44
44
int candy = 1 ;
45
45
while (candies > 0 ) {
46
- for (int person = 1 ; person <= num_people && candies > 0 ; person ++, candy ++) {
46
+ for (int person = 1 ; person <= numPeople && candies > 0 ; person ++, candy ++) {
47
47
if (candies < candy ) {
48
48
map .put (person , map .getOrDefault (person , 0 ) + candies );
49
49
candies -= candy ;
@@ -54,8 +54,8 @@ public int[] distributeCandies(int candies, int num_people) {
54
54
}
55
55
}
56
56
}
57
- int [] result = new int [num_people ];
58
- for (int i = 1 ; i <= num_people ; i ++) {
57
+ int [] result = new int [numPeople ];
58
+ for (int i = 1 ; i <= numPeople ; i ++) {
59
59
if (map .containsKey (i )) {
60
60
result [i - 1 ] = map .get (i );
61
61
} else {
You can’t perform that action at this time.
0 commit comments