Easy to understand python solution

  • 0
    def canConstruct(self, ransomNote, magazine):
        :type ransomNote: str
        :type magazine: str
        :rtype: bool
        for element in ransomNote:
            if element not in magazine:
                return False
                i = magazine.find(element)
                magazine = magazine[:i] + magazine[i+1:]
        return True

Log in to reply

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