Python solution


  • 0
    R

    """
    def canConstruct(self, ransomNote, magazine):
    c1 = collections.Counter(ransomNote)
    c2 = collections.Counter(magazine)
    for k,v in c1.items():
    if k not in magazine:
    return False
    if k in c2:
    if c1[k]!=c2[k]:
    c2[k] -= 1
    if c2[k] <= 0:
    return False
    if c2[k] < c1[k]:
    return False

            return True
    

    """
    """


Log in to reply
 

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