Python using Counter - really short 2 lines


  • 0
    M
    def canConstruct(self, ransomNote, magazine):
            r = collections.Counter(ransomNote)
            m = collections.Counter(magazine)
            return r & m == r
    

Log in to reply
 

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