{"id":174,"date":"2018-05-22T21:13:49","date_gmt":"2018-05-22T13:13:49","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=174"},"modified":"2018-11-27T17:14:39","modified_gmt":"2018-11-27T09:14:39","slug":"383-ransom-note","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=174","title":{"rendered":"383. Ransom Note"},"content":{"rendered":"<p>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.<\/p>\n<p>Each letter in the magazine string can only be used once in your ransom note.<\/p>\n<p><b>Note:<\/b><br \/>\nYou may assume that both strings contain only lowercase letters.<\/p>\n<pre>canConstruct(\"a\", \"b\") -&gt; false\r\ncanConstruct(\"aa\", \"ab\") -&gt; false\r\ncanConstruct(\"aa\", \"aab\") -&gt; true<\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution:\r\n    def canConstruct(self, ransomNote, magazine):\r\n        &quot;&quot;&quot;\r\n        :type ransomNote: str\r\n        :type magazine: str\r\n        :rtype: bool\r\n        &quot;&quot;&quot;\r\n        magazine = list(magazine)\r\n        for i in ransomNote:\r\n            if i in magazine:\r\n                magazine.remove(i)\r\n            else:\r\n                return False\r\n        return True\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given an arbitrary ransom note string and another strin<a href=\"https:\/\/www.ccagml.com\/?p=174\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">383. Ransom Note<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/174"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=174"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/174\/revisions"}],"predecessor-version":[{"id":175,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/174\/revisions\/175"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}