{"id":21,"date":"2017-03-15T18:47:53","date_gmt":"2017-03-16T01:47:53","guid":{"rendered":"http:\/\/zxi.mytechroad.com\/blog\/?p=21"},"modified":"2018-04-19T08:45:48","modified_gmt":"2018-04-19T15:45:48","slug":"leetcode-sum-of-two-integers","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/leetcode\/leetcode-sum-of-two-integers\/","title":{"rendered":"\u82b1\u82b1\u9171 Leetcode 371. Sum of Two Integers"},"content":{"rendered":"<p>Calculate the sum of two integers <i>a<\/i> and <i>b<\/i>, but you are <b>not allowed<\/b> to use the operator <code>+<\/code> and <code>-<\/code>.<\/p>\n<pre class=\"lang:c++ decode:true \">class Solution {\r\npublic:\r\n    int getSum(int a, int b) {\r\n        return b==0?a:getSum(a^b, (a&amp;b)&lt;&lt;1);\r\n    }\r\n};<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. class Solution { public:&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[16,17],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-leetcode","tag-bit","tag-recursion","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":2,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":2740,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions\/2740"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}