From 9e7354fc5c68c8299ea286a1203c06a7aa775aef Mon Sep 17 00:00:00 2001 From: Lam Haoyin Date: Thu, 3 Feb 2022 21:38:50 +0800 Subject: [PATCH] add: 0100 --- more/0100.cpp | 16 ++++++++++++++++ more/CMakeLists.txt | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 more/0100.cpp 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)