📝 Update 0383.赎金信.md with python3

This commit is contained in:
to_Geek
2023-11-10 22:00:29 +08:00
parent 139a4db485
commit 09835e7444

View File

@ -214,6 +214,19 @@ class Solution:
return all(ransomNote.count(c) <= magazine.count(c) for c in set(ransomNote)) return all(ransomNote.count(c) <= magazine.count(c) for c in set(ransomNote))
``` ```
(版本六使用count(简单易懂)
```python3
class Solution:
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
for char in ransomNote:
if char in magazine and ransomNote.count(char) <= magazine.count(char):
continue
else:
return False
return True
```
### Go ### Go
```go ```go