add: 0100

This commit is contained in:
Lam Haoyin 2022-02-03 21:38:50 +08:00
parent e28411d091
commit 9e7354fc5c
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
2 changed files with 17 additions and 1 deletions

16
more/0100.cpp Normal file
View File

@ -0,0 +1,16 @@
/**
* Definition for a binary tree node.
*/
struct TreeNode {
int val;
TreeNode* left;
TreeNode* right;
explicit TreeNode(int x = 0, TreeNode* left = nullptr, TreeNode* right = nullptr) : val(x), left(left), right(right) {}
};
class Solution {
public:
static bool isSameTree(TreeNode* p, TreeNode* q) {
return (p == q) || (p && q && p->val == q->val && isSameTree(p->left, q->left) && isSameTree(p->right, q->right));
}
};

View File

@ -3,4 +3,4 @@ PROJECT(more)
SET(CMAKE_CXX_STANDARD 23) SET(CMAKE_CXX_STANDARD 23)
ADD_EXECUTABLE(more 0015.cpp) ADD_EXECUTABLE(more 0100.cpp)