Straightforward Python Solution


  • 0
    S
    class Solution(object):
        def findContentChildren(self, g, s):
            """
            :type g: List[int]
            :type s: List[int]
            :rtype: int
            """
            ans = 0
            g,s = sorted(g),sorted(s)
            i,j = 0,0
            while True:
                if i >= len(g):
                    break
                if j >= len(s):
                    break
                if g[i] <= s[j]:
                    ans += 1
                    i += 1
                    j += 1
                else:
                    j += 1
                
            return ans
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.