383. Ransom Note
magazineの文字列がransomNoteで構成されているかどうかのチェックだった気がする。。
辞書型の復習
class Solution:
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
wordDict = {}
for i in ransomNote:
wordDict[i]=ransomNote.count(i)
ransomNote.replace(i,"")
counter = 0
for i in wordDict:
if(i not in magazine or magazine.count(i) < wordDict[i]):
counter += 1
if(counter == 0):
return 1
else:
return 0