class Solution {
func numRescueBoats(_ people: [Int], _ limit: Int) -> Int {
let arr = people.sorted()
var i: Int = 0
var j: Int = people.count - 1
var count: Int = 0
while i <= j {
count += 1
if arr[i] + arr[j] <= limit {
i += 1
}
j -= 1
}
return count
}
}