Skip to content

Commit

Permalink
📝 Update 0383.赎金信.md with python3
Browse files Browse the repository at this point in the history
  • Loading branch information
qiu121 committed Nov 10, 2023
1 parent 139a4db commit 09835e7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions problems/0383.赎金信.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ class Solution:
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
Expand Down

0 comments on commit 09835e7

Please sign in to comment.