diff --git a/more/0100.cpp b/more/0100.cpp new file mode 100644 index 0000000..656f5e2 --- /dev/null +++ b/more/0100.cpp @@ -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)); + } +}; \ No newline at end of file diff --git a/more/CMakeLists.txt b/more/CMakeLists.txt index aa5b425..c2102a4 100644 --- a/more/CMakeLists.txt +++ b/more/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(more) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(more 0015.cpp) +ADD_EXECUTABLE(more 0100.cpp)