添加 0383.赎金信.md Python3版本

使用collections.Counter实现
This commit is contained in:
shuwen
2021-08-13 10:45:58 +08:00
committed by GitHub
parent 70524a1521
commit 5055e15cd9

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