본문 바로가기

IT/코딩테스트

[Leetcode] 383. Ransom Note

728x90

https://leetcode.com/problems/ransom-note/

class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
        maga = list(magazine)

        for l in ransomNote:
            if not l in maga:
                return False
            else:
                maga.remove(l)
        return True
728x90