{"id":147,"date":"2017-09-14T19:43:17","date_gmt":"2017-09-14T11:43:17","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=147"},"modified":"2018-11-27T16:44:06","modified_gmt":"2018-11-27T08:44:06","slug":"136-single-number","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=147","title":{"rendered":"136. Single Number"},"content":{"rendered":"<p>Given a\u00a0<strong>non-empty<\/strong>\u00a0array of integers, every element appears\u00a0<em>twice<\/em>\u00a0except for one. Find that single one.<\/p>\n<p><strong>Note:<\/strong><\/p>\n<p>Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<pre><strong>Input:<\/strong> [2,2,1]\r\n<strong>Output:<\/strong> 1\r\n<\/pre>\n<p><strong>Example 2:<\/strong><\/p>\n<pre><strong>Input:<\/strong> [4,1,2,1,2]\r\n<strong>Output:<\/strong> 4<\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def singleNumber(self, nums):\r\n        &quot;&quot;&quot;\r\n        :type nums: List[int]\r\n        :rtype: int\r\n        &quot;&quot;&quot;\r\n        return -(sum(nums) - 2 * sum(set(nums)))\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given a\u00a0non-empty\u00a0array of integers, every element appe<a href=\"https:\/\/www.ccagml.com\/?p=147\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">136. Single Number<\/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\/147"}],"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=147"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":148,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions\/148"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}