Skip to content

Commit 09835e7

Browse files
committed
📝 Update 0383.赎金信.md with python3
1 parent 139a4db commit 09835e7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

problems/0383.赎金信.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ class Solution:
214214
return all(ransomNote.count(c) <= magazine.count(c) for c in set(ransomNote))
215215
```
216216

217+
(版本六)使用count(简单易懂)
218+
219+
```python3
220+
class Solution:
221+
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
222+
for char in ransomNote:
223+
if char in magazine and ransomNote.count(char) <= magazine.count(char):
224+
continue
225+
else:
226+
return False
227+
return True
228+
```
229+
217230
### Go:
218231
219232
```go

0 commit comments

Comments
 (0)