diff --git a/problems/0383.赎金信.md b/problems/0383.赎金信.md index f2c1685a..d4b73848 100644 --- a/problems/0383.赎金信.md +++ b/problems/0383.赎金信.md @@ -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