Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit146bdb4

Browse files
authored
Merge pull requestneetcode-gh#1426 from fulcus/patch-2
Create 383-Ransom-Note.py
2 parentseaf8d38 +b004d33 commit146bdb4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎python/383-Ransom-Note.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fromcollectionsimportCounter
2+
3+
classSolution:
4+
defcanConstruct(self,ransomNote:str,magazine:str)->bool:
5+
r_counter=Counter(ransomNote)
6+
m_counter=Counter(magazine)
7+
# magazine contains (>=) ransomNote
8+
forcinransomNote:
9+
ifm_counter[c]<r_counter[c]:
10+
returnFalse
11+
returnTrue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp