标签:style class blog code color for
/** * Definition for binary tree * 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) { int v = ((p == NULL) << 1) + (q == NULL); if (v == 0x2 || v == 0x1) return false; // one NULL the other not NULL if (v == 0x3) return true; // both NULL if (p->val != q->val) return false; // value not match return isSameTree(p->left, q->left) // check subtree && isSameTree(p->right, q->right); } };
继续水
LeetCode SameTree,布布扣,bubuko.com
标签:style class blog code color for
原文地址:http://www.cnblogs.com/lailailai/p/3806014.html