題目:Kids With the Greatest Number of Candies
難度:Easy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public class Solution { public IList<bool> KidsWithCandies(int[] candies, int extraCandies) { var greatestBeforeGiving = candies.ToList().OrderBy(i => i).Last();
var result = new bool[candies.Length];
for (var i = 0; i < candies.Length; i++) { result[i] = (candies[i] + extraCandies) >= greatestBeforeGiving ? true : false; }
return result; } }
|