Leetcode 383. Ransom Note | | Leetcode 383. Ransom Note 文章作者:Tyan博客:noahsnail.com | CSDN | 简书 1. Description 2. Solution Version 1 1234567891011class Solution: def canConstruct(self, ransomNote: str, magazine: str) -> bool: ransom = Counter(ransomNote) mag = Counter(magazine) for k, _ in ransom.items(): if k in mag: if ransom[k] > mag[k]: return False else: return False return True Reference https://leetcode.com/problems/ransom-note/ 如果有收获,可以请我喝杯咖啡! 赏 微信打赏 支付宝打赏