{"id":9644,"date":"2022-04-16T08:06:42","date_gmt":"2022-04-16T15:06:42","guid":{"rendered":"https:\/\/zxi.mytechroad.com\/blog\/?p=9644"},"modified":"2022-04-16T08:07:05","modified_gmt":"2022-04-16T15:07:05","slug":"leetcode-2235-add-two-integers","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/math\/leetcode-2235-add-two-integers\/","title":{"rendered":"\u82b1\u82b1\u9171 LeetCode 2235. Add Two Integers"},"content":{"rendered":"\n<p>Given two integers&nbsp;<code>num1<\/code>&nbsp;and&nbsp;<code>num2<\/code>, return&nbsp;<em>the&nbsp;<strong>sum<\/strong>&nbsp;of the two integers<\/em>.<\/p>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted;crayon:false\"><strong>Input:<\/strong> num1 = 12, num2 = 5\n<strong>Output:<\/strong> 17\n<strong>Explanation:<\/strong> num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.\n<\/pre>\n\n\n\n<p><strong>Example 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted;crayon:false\"><strong>Input:<\/strong> num1 = -10, num2 = 4\n<strong>Output:<\/strong> -6\n<strong>Explanation:<\/strong> num1 + num2 = -6, so -6 is returned.\n<\/pre>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>-100 &lt;= num1, num2 &lt;= 100<\/code><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Solution: Just sum them up<\/strong><\/h2>\n\n\n\n<p>Time complexity: O(1)<br>Space complexity: O(1)<\/p>\n\n\n\n<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">C++<\/h2>\n<div class=\"tabcontent\">\n\n<pre lang=\"c++\">\/\/ Author: Huahua\nclass Solution {\npublic:\n  int sum(int num1, int num2) {\n    return num1 + num2;\n  }\n};\n<\/pre>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Given two integers&nbsp;num1&nbsp;and&nbsp;num2, return&nbsp;the&nbsp;sum&nbsp;of the two integers. Example 1: Input: num1 = 12, num2 = 5 Output: 17 Explanation: num1 is 12, num2 is 5,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[222],"class_list":["post-9644","post","type-post","status-publish","format-standard","hentry","category-math","tag-easy","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/9644","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=9644"}],"version-history":[{"count":2,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/9644\/revisions"}],"predecessor-version":[{"id":9646,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/9644\/revisions\/9646"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=9644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=9644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=9644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}