nlogn solution
Intuition\n Describe your first thoughts on how to solve this problem. \nsort & Two pointer\n# Approach\n Describe your approach to solving the problem. \ntake 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nsort & Two pointer\n# Approach\n<!-- Describe your approach to solving the problem. -->\ntake light and heavy person if their weights less or equal to limit they can go together else only heavy person .\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nsort----->>>> nlogn\ntwo pointer n\ntotal=nlogn+n=O(nlogn);\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1) bcaz no extra space;\n\n# Code\n```\nclass Solution {\npublic:\n    int numRescueBoats(vector<int>& p, int l) {\n        sort(p.begin(),p.end());\n        int c=0;\n        int i=0,j=p.size()-1;\n        while(i<=j){\n            if(p[i]+p[j]<=l){\n           i++;\n           j--;\n           }\n            else\n           j--;\n           c++;\n        }\n        return c;\n    }\n};\n```
['Two Pointers', 'Sorting']