1
from collections import Counter
2

3

4
class Solution:
5
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
6

7
ransomNote_count = dict(Counter(ransomNote))
8
magazine_count = dict(Counter(magazine))
9

10
for key, value in ransomNote_count.items():
11

12
if key in magazine_count:
13
if value <= magazine_count[key]:
14
continue
15
else:
16
return False
17

18
return False
19

20
return True

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0