{"id":161,"date":"2017-10-22T18:59:23","date_gmt":"2017-10-22T10:59:23","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=161"},"modified":"2018-11-27T17:00:25","modified_gmt":"2018-11-27T09:00:25","slug":"217-contains-duplicate","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=161","title":{"rendered":"217. Contains Duplicate"},"content":{"rendered":"<p>Given an array of integers, find if the array contains any duplicates.<\/p>\n<p>Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<pre><strong>Input:<\/strong> [1,2,3,1]\r\n<strong>Output:<\/strong> true<\/pre>\n<p><strong>Example 2:<\/strong><\/p>\n<pre><strong>Input: <\/strong>[1,2,3,4]\r\n<strong>Output:<\/strong> false<\/pre>\n<p><strong>Example 3:<\/strong><\/p>\n<pre><strong>Input: <\/strong>[1,1,1,3,3,4,3,2,4,2]\r\n<strong>Output:<\/strong> true<\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def containsDuplicate(self, nums):\r\n        &quot;&quot;&quot;\r\n        :type nums: List[int]\r\n        :rtype: bool\r\n        &quot;&quot;&quot;\r\n        if nums:\r\n            list_len = len(nums)\r\n            set_len = len(set(nums))\r\n            if list_len == set_len:\r\n                return False\r\n            else:\r\n                return True\r\n        else:\r\n            return False\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given an array of integers, find if the array contains <a href=\"https:\/\/www.ccagml.com\/?p=161\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">217. Contains Duplicate<\/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\/161"}],"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=161"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions"}],"predecessor-version":[{"id":162,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions\/162"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}