Aluminum21
Junior Member
C#:
public class Solution
{
public int NumRescueBoats(int[] people, int limit)
{
Array.Sort(people);
int left = 0;
int right = people.Length - 1;
int result = 0;
while (left <= right)
{
int remain = limit - people[right];
if (people[left] <= remain)
{
left++;
}
right--;
result++;
}
return result;
}
}
á à






