Created
December 3, 2020 21:15
-
-
Save kingsamadesu/7d1e642a35d7702c3507622e81aea3e2 to your computer and use it in GitHub Desktop.
1431. Kids With the Greatest Number of Candies -with java- (leetcode.com)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Your memory usage beats 70.77 % of java submissions. | |
*/ | |
class Solution { | |
public List<Boolean> kidsWithCandies(int[] candies, int extraCandies) { | |
List<Boolean> list = new ArrayList<>(); | |
int max = 0; | |
for(int i = 0 ; i < candies.length ; i++){ | |
if(max<candies[i])max = candies[i]; | |
} | |
for(int i = 0 ; i < candies.length ; i++){ | |
list.add((max - candies[i])<=extraCandies); | |
} | |
return list; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment