383.Ransom Note === [link](https://leetcode.com/problems/ransom-note/description/) 想法: 要剪出的字數目一定要比magazine上面的多,這樣才可以拼湊出來。 解法: 善用Python的counter功能,直接比較兩邊大小,判斷T或是F。 程式碼: ``` from collections import Counter class Solution(object): def canConstruct(self, ransomNote, magazine): """ :type ransomNote: str :type magazine: str :rtype: bool """ ct_ransom=Counter(ransomNote) ct_magazine=Counter(magazine) for i in ct_ransom: if ct_ransom[i]>ct_magazine[i]: return False return True ```