Python task

任务一:

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

 

任务二:

 

posted @ 2024-10-31 11:49  sunshine丶23  阅读(1)  评论(0编辑  收藏  举报