Skip to content

Commit

Permalink
Merge pull request neetcode-gh#1426 from fulcus/patch-2
Browse files Browse the repository at this point in the history
Create 383-Ransom-Note.py
  • Loading branch information
Ahmad-A0 authored Nov 19, 2022
2 parents eaf8d38 + b004d33 commit 146bdb4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions python/383-Ransom-Note.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from collections import Counter

class Solution:
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
r_counter = Counter(ransomNote)
m_counter = Counter(magazine)
# magazine contains (>=) ransomNote
for c in ransomNote:
if m_counter[c] < r_counter[c]:
return False
return True

0 comments on commit 146bdb4

Please sign in to comment.