🌻|| C++ || Easy Approach || PROPER EXPLANATION
Approach 1\n\nStep 1: Just check for all possible pairs which can go on single boat without breaking the limit constraint and increment the number of boat count
### Approach 1\n```\nStep 1: Just check for all possible pairs which can go on single boat without breaking the limit constraint and increment the number of boat count required.\nStep 2 : If a pair is not found or a person is left alone than that he/she have to go out with a seprate boat. And increament the count for that.\n\nTime complexity for this approach will be  O(N^2);\n```\n\n### Approach 2\n```\nStep 1: Sort the given people array because it will help us to find people with heavier weights.\nFor minimizing the number of boats we can pairup the people of one lighter and one heavier in weight together only if they doesn\'t cross the given limit.\nStep 2: Use Two pointer approach means put a left pointer at the index 0 and a right pointer at the end of the people array and keep a count variable which will\nbe storing the minimum number of boats required to carry all. And Calculate sum which will be equal to people[i] + people[j]\n\nPossible cases that can happen\nCase 1: if(sum<=limit)\nThan they can go in a boat together so just increase the count of boat and make the left pointer \'left++\' and right pointer \'right--\'.\nCase 2: if(sum>limit)\nThan in that situation there can be minimum number of boats only if seprately send the heavier boat go alone and the lighter weight go in the next turn.\nAND only increment the boat count and decrement your right pointer.\n\nTime complexity - O(N Log N)\n```\n\n### ALGORITHM FOR APPROACH-2\n```\nSTART\nSTEP-1. Sort the given array\nStep-2: Initialize boat_count<-0,left<-0,right<-people.size()-1 (means at last index).\nStep-3: REPEAT STEP 4 to 8 UNTIL left<=right\nStep-4: Initialize result<-people[left]+people[right].\nStep-5: FOLLOW STEP-6 if(result<=limit)\nStep-6: boat_count<- boat_count, left<-left+1,right<-right-1.\nStep-7: FOLLOW STEP-8 if(result>limit)\nStep-8: boat_count<- boat_count,right<-right-1.\nStep-9 RETURN boat_count.\n```\n\n### CODE\n```\nclass Solution {\npublic:\n    int numRescueBoats(vector<int>& people, int limit)\n    {\n        sort(people.begin(), people.end());\n        int boat_count = 0, left = 0 , right = people.size() -1;\n        while(left <= right){\n        int result = people[left] + people[right];\n        if(result <= limit)\n       {\n            \n            boat_count++;\n            left++;\n            right--;\n        }\n        if(result > limit)\n        {\n            boat_count++;\n            right--;\n        }\n    }\n        return boat_count;\n    }\n};\n```
['Two Pointers', 'C']