A simple O(NlogN) Python Solution


  • 0
    F
    class Solution(object):
        def findContentChildren(self, g, s):
            """
            :type g: List[int]
            :type s: List[int]
            :rtype: int
            """
            g.sort()
            s.sort()
            count = 0
            while g != [] and s != []:
                if g[-1] <= s[-1]:
                    count += 1
                    s.pop()
                g.pop()
            return count
    

Log in to reply
 

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