Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7be33e9

Browse files
committed
增加NO1431
1 parent 5f251a7 commit 7be33e9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Array/No1431.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package Array;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
* @author tujietg
8+
* @date 6/1/20 10:43 AM
9+
*/
10+
public class No1431 {
11+
public List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
12+
int n = candies.length;
13+
int maxCandies = 0;
14+
for (int i = 0; i < n; ++i) {
15+
maxCandies = Math.max(maxCandies, candies[i]);
16+
}
17+
List<Boolean> ret = new ArrayList<Boolean>();
18+
for (int i = 0; i < n; ++i) {
19+
ret.add(candies[i] + extraCandies >= maxCandies);
20+
}
21+
return ret;
22+
}
23+
}

0 commit comments

Comments
 (0)