TWO-POINTERS || C++
Code\n\nclass Solution {\npublic:\n    int numRescueBoats(vector<int>& v, int limit) {\n        sort(v.begin(),v.end());\n        int i = 0, j=v.size()-1,ans=0;
# Code\n```\nclass Solution {\npublic:\n    int numRescueBoats(vector<int>& v, int limit) {\n        sort(v.begin(),v.end());\n        int i = 0, j=v.size()-1,ans=0;\n        while(i<=j){\n            if(j-1>=i&&v[j]+v[j-1]<=limit){\n                j-=2;\n            }\n            else if(v[j]+v[i]<=limit){\n                j--;i++;\n            }else{\n                j--;\n            }\n            ans++;\n        }\n        return ans;\n    }\n};\n```
['C++']