{"id":118,"date":"2017-08-03T20:17:04","date_gmt":"2017-08-03T12:17:04","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=118"},"modified":"2018-11-27T16:18:07","modified_gmt":"2018-11-27T08:18:07","slug":"67-add-binary","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=118","title":{"rendered":"67. Add Binary"},"content":{"rendered":"<p>Given two binary strings, return their sum (also a binary string).<\/p>\n<p>The input strings are both\u00a0<strong>non-empty<\/strong>\u00a0and contains only characters\u00a0<code>1<\/code>\u00a0or\u00a0<code>0<\/code>.<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<pre><strong>Input:<\/strong> a = \"11\", b = \"1\"\r\n<strong>Output:<\/strong> \"100\"<\/pre>\n<p><strong>Example 2:<\/strong><\/p>\n<pre><strong>Input:<\/strong> a = \"1010\", b = \"1011\"\r\n<strong>Output:<\/strong> \"10101\"<\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def addBinary(self, a, b):\r\n        &quot;&quot;&quot;\r\n        :type a: str\r\n        :type b: str\r\n        :rtype: str\r\n        &quot;&quot;&quot;\r\n        a = int(a, 2)\r\n        b = int(b, 2)\r\n        c = a+b\r\n        return str(bin(c))[2:]\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given two binary strings, return their sum (also a bina<a href=\"https:\/\/www.ccagml.com\/?p=118\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">67. Add Binary<\/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\/118"}],"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=118"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/119"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}