TIL/Coding Test

[LeetCode] assign cookies (Python)

반응형

풀었던 문제를 파이썬으로 다시 풀어보기. 분명 풀었던 문제임에도 낯설다... 

 

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

from typing import List

class cote0401_455_assignCookies:
    def findContentChildren(self, g: List[int], s: List[int]) -> int:
        g.sort()
        s.sort()

        index=0
        count=0

        for i in range(len(s)):
            if index > len(g)-1:
                return count
            if g[index] <= s[i]:
                count+=1
                index+=1
            i+=1
        
        return count



 

728x90
반응형