Merge pull request #599 from shuwenlan/master

添加 0383.赎金信.md Python3版本
This commit is contained in:
程序员Carl
2021-08-14 10:55:50 +08:00
committed by GitHub

View File

@ -209,6 +209,22 @@ class Solution(object):
return True
```
Python写法四
```python3
class Solution:
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
c1 = collections.Counter(ransomNote)
c2 = collections.Counter(magazine)
x = c1 - c2
#x只保留值大于0的符号当c1里面的符号个数小于c2时不会被保留
#所以x只保留下了magazine不能表达的
if(len(x)==0):
return True
else:
return False
```
Go
```go