Skip to content

Instantly share code, notes, and snippets.

@kingsamadesu
Created December 3, 2020 21:15
Show Gist options
  • Save kingsamadesu/7d1e642a35d7702c3507622e81aea3e2 to your computer and use it in GitHub Desktop.
Save kingsamadesu/7d1e642a35d7702c3507622e81aea3e2 to your computer and use it in GitHub Desktop.
1431. Kids With the Greatest Number of Candies -with java- (leetcode.com)
/*
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