JavaScript | 92% faster | Two Pointers
Approach: \nSort the peoples array in any order. traverse the array from left(i) and right(j) with two pointers. if the sum people[i]+people[j] > limitincrement
**Approach:** \nSort the peoples array in any order. traverse the array from left`(i)` and right`(j)` with two pointers. if the sum `people[i]+people[j] > limit `increment the i to i++ else if the` sum <= limit` increment i to i++ and decrement j to j--;\n```\nvar numRescueBoats = function(people, limit) {\n    people = people.sort((a, b) => b - a);\n    let i = 0, j = people.length-1;\n    let count = 0;\n    while (i <= j) {\n        if (people[i] + people[j] <= limit) j--;\n        i++;\n        count++;\n    }\n    return count;\n};\n```
['JavaScript']