simple 2 pointers approach
Intuition\n Describe your first thoughts on how to solve this problem. \njust sort the array \nwe canb put any 2 in boat \norder of people array does not matter
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\njust sort the array \nwe canb put any 2 in boat \norder of people array does not matter\ngreedy intuition is that with a big peopl each time can a small people be adjusted if yes send them in the same boat or else send the big poeple alone with a single boat\nthis intuition works while doing a dry run over sample test cases \nas well as pass all test cases on Leetcode\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int numRescueBoats(vector<int>& p, int limit) {\n\n        //first read thew question well\n        //constraint limit\n        //cannot carry more than 2 persons at a  time\n\n        //can carry any 2 person from the array \n        //order does not matter\n        sort(p.begin(),p.end());\n        int l=0;\n        int high=p.size()-1;\n        int ans=0;\n        while(high>=l){\n            int curr=p[high];\n            if(curr+p[l]<=limit){\n                ans++;\n                high--;\n                l++;\n\n            }else{\n                ans++;\n                high--;\n\n            }\n        }\n        return ans;\n        \n    }\n};\n```
['C++']