본문 바로가기
Problem Solving

1-3. Assign Cookies (LeetCode 455)

by tls1107 2021. 7. 7.
728x90
반응형


 

class Solution {
    public int findContentChildren(int[] g, int[] s) {
        int answer = 0;
        int G=0,S=0;
        
        Arrays.sort(g);
        Arrays.sort(s);
        
        while(G < g.length && S < s.length ){
            if(g[G] <= s[S]){
                G++;
                S++;
                answer++;
            }
            else S++;
        }
        return answer;
    }
}

https://leetcode.com/problems/assign-cookies/

 

Assign Cookies - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

728x90
반응형

댓글