class Solution {
public int numRescueBoats(int[] people, int limit) {
if (people ==null || people.length ==0) {
return 0;
}
Arrays.sort(people);
int shipNum =0;
int l =0;
int r =people.length-1;
while(l <=r) {
if (people[l] +people[r] <=limit) {
l++;
}
r--;
shipNum++;
}
return shipNum;
}
}