文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
1. Description
Ransom Note2. Solution
- Version 1
class Solution:
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
ransom = Counter(ransomNote)
mag = Counter(magazine)
for k, _ in ransom.items():
if k in mag:
if ransom[k] > mag[k]:
return False
else:
return False
return True
网友评论