Ransom Note
Question
Example
canConstruct("a", "b") -> false
canConstruct("aa", "ab") -> false
canConstruct("aa", "aab") -> trueHint
Answer
solution:
class Solution(object):
def canConstruct(self, ransomNote, magazine):
"""
:type ransomNote: str
:type magazine: str
:rtype: bool
"""
ransom = list(ransomNote)
mag = list(magazine)
for i in ransom:
if i in mag:
mag.remove(i)
else:
return False
return TrueKnowledge:
Last updated