国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 伊春市| 建水县| 深水埗区| 禹城市| 五华县| 鹤岗市| 靖江市| 平乐县| 和硕县| 寻甸| 乌拉特后旗| 郧西县| 太白县| 曲松县| 怀远县| 巩义市| 瑞丽市| 抚远县| 察雅县| 长宁区| 探索| 平南县| 门源| 开封县| 枞阳县| 苗栗县| 望城县| 芜湖县| 涿州市| 萨迦县| 黔西县| 桃源县| 香港 | 鄂州市| 聂荣县| 华蓥市| 五华县| 海原县| 临邑县| 德格县| 丰台区|