{"id":1831,"date":"2016-02-13T17:18:41","date_gmt":"2016-02-13T09:18:41","guid":{"rendered":"http:\/\/boweihe.me\/?p=1831"},"modified":"2016-02-13T17:18:41","modified_gmt":"2016-02-13T09:18:41","slug":"leetcode-100-same-tree","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=1831","title":{"rendered":"LeetCode #100. Same Tree"},"content":{"rendered":"<p>\u9898\u76ee\uff1ahttps:\/\/leetcode.com\/problems\/same-tree\/<br \/>\n\u5206\u6790\uff1a\u6ce8\u610f\u5224\u65adNULL\u60c5\u51b5\uff0c\u7528\u9012\u5f52\u505a<br \/>\n\u4ee3\u7801\uff1a\uff08\u79d2AC\u6709\u6728\u6709\uff01\uff09<\/p>\n<pre class=\"lang:c++ decode:true \">\/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n *\/\nclass Solution {\npublic:\n    bool isSameTree(TreeNode* p, TreeNode* q) {\n        if(p == NULL &amp;&amp; q == NULL)\n            return true;\n        if(p == NULL || q == NULL)\n            return false;\n        if(p-&gt;val != q-&gt;val)\n            return false;\n        return isSameTree(p-&gt;left, q-&gt;left) &amp;&amp; isSameTree(p-&gt;right, q-&gt;right);\n    }\n};<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\uff1ahttps:\/\/leetcode.com\/problems\/same-tree\/ \u5206\u6790\uff1a\u6ce8\u610f\u5224\u65adNULL\u60c5\u51b5\uff0c\u7528\u9012\u5f52\u505a \u4ee3\u7801\uff1a\uff08\u79d2AC\u6709\u6728\u6709\uff01\uff09 \/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; *\/ class Solution { public: bool isSameTree(TreeNode* p, TreeNode* q) { if(p == NULL &amp;&amp; q == NULL) return true; if(p [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[66],"class_list":["post-1831","post","type-post","status-publish","format-standard","hentry","category-study","tag-leetcode-oj"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1831"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1831\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}