10000 Create 383_Ransom_Note.py · KanuKim97/Algorithm@19bd2be · GitHub
[go: up one dir, main page]

Skip to content

Commit 19bd2be

Browse files
committed
Create 383_Ransom_Note.py
1 parent 9ddc82f commit 19bd2be

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

leetCode/Easy/383_Ransom_Note.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
3+
ran_cnt = dict(Counter(list(ransomNote)))
4+
mag_cnt = dict(Counter(list(magazine)))
5+
6+
ran_key = ran_cnt.keys()
7+
mag_key = mag_cnt.keys()
8+
9+
for keys in ran_key :
10+
if keys not in mag_key :
11+
return False
12+
break
13+
14+
if mag_cnt[keys] - ran_cnt[keys] < 0 :
15+
return False
16+
break
17+
18+
return True

0 commit comments

Comments
 (0)
0