国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

Ransom Note

2019-11-08 20:16:02
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.

Each letter in the magazine string can only be used once in your ransom note.

Note:You may assume that both strings contain only lowercase letters.

canConstruct("a", "b") -> falsecanConstruct("aa", "ab") -> falsecanConstruct("aa", "aab") -> true

class Solution(object):    def canConstruct(self, ransomNote, magazine):        """        :type ransomNote: str        :type magazine: str        :rtype: bool        """        import collections        return not collections.Counter(ransomNote) - collections.Counter(magazine)


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 宝清县| 金秀| 连云港市| 安徽省| 光山县| 灌南县| 平罗县| 花垣县| 武汉市| 文成县| 政和县| 夏津县| 蒙山县| 沙雅县| 钦州市| 永修县| 新源县| 科技| 高安市| 嘉祥县| 焦作市| 兴和县| 鹿邑县| 连平县| 凤凰县| 乐山市| 五大连池市| 神农架林区| 阿勒泰市| 民乐县| 元谋县| 乐都县| 宁安市| 墨竹工卡县| 来宾市| 建湖县| 富民县| 岗巴县| 青河县| 固阳县| 府谷县|