Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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;
    }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ start thread later 
Cpp :: cosnt cast 
Cpp :: C++ if...else 
Cpp :: how to insert variable into string c++ 
Cpp :: c++ copy with transform 
Cpp :: xor in c++ 
Cpp :: iff cpp 
Cpp :: c++ rgb code 
Cpp :: C++ Display Numbers from 1 to 5 
Cpp :: c++ CRL multiline string 
Cpp :: c++ call overriden method from constructor 
Cpp :: spyder enviroment 
Cpp :: boost filesystem get filename without exetention from path 
Cpp :: void linux java 
Cpp :: compile c++ program 
Cpp :: constructor init list 
Cpp :: hola mundo c++ 
Cpp :: c++ union set q5 
Cpp :: 1603. Design Parking System leetcode solution in c++ 
Cpp :: what is a string called in c++ 
Cpp :: c++ rainbow text 
Cpp :: http://dcnet.ddns.ma/Connecter_Tuteur 
Cpp :: how to implement stack 
Cpp :: c++ array on heap 
Cpp :: how to include a library in arduino 
Cpp :: Arduino Counting 
Cpp :: what does for do in c++ 
C :: malloc is undefined 
C :: c colour 
C :: reading string with spaces in c 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =