Python task

sunshine丶23 / 2025-02-21 / 原文

任务一:

Leetcode 383

class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
        cnt = Counter(magazine)
        for c in ransomNote:
            cnt[c] -= 1
            if cnt[c] < 0:
                return False
        return True

 

任务二: