Horje
Boats to Save People leetcode solution in c++ Code Example
Boats to Save People leetcode solution in c++
class Solution {
public:
    int numRescueBoats(vector<int>& people, int limit) {
        int n=people.size();
        sort(people.begin(),people.end());
        int cnt=0;
        int l=0, r=n-1;
        while(l<=r)
        {
            if(people[l]+people[r]<=limit)
                l++;
            r--;
            cnt++;
        }
        return cnt;
    }
};




Cpp

Related
the statement vector vector int matrix(100 vector int (50 100) ) declares Code Example the statement vector vector int matrix(100 vector int (50 100) ) declares Code Example
how to measure cpp code performace Code Example how to measure cpp code performace Code Example
merge sort in descending order c++ Code Example merge sort in descending order c++ Code Example
c++ call overriden method from constructor Code Example c++ call overriden method from constructor Code Example
left recursion program in c++ Code Example left recursion program in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9