From eb1bbfb9c677757cbb258a368dbab53a0f8261fa Mon Sep 17 00:00:00 2001 From: Sainnhe Park Date: Mon, 30 Jan 2023 20:18:01 +0800 Subject: [PATCH] s0226 --- src/s0226_invert_binary_tree.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/s0226_invert_binary_tree.cpp diff --git a/src/s0226_invert_binary_tree.cpp b/src/s0226_invert_binary_tree.cpp new file mode 100644 index 0000000..9b44b3b --- /dev/null +++ b/src/s0226_invert_binary_tree.cpp @@ -0,0 +1,9 @@ +#include "s0226_invert_binary_tree.hpp" + +TreeNode *S0226::invertTree(TreeNode *root) { + if (root == nullptr) return nullptr; + TreeNode *tmp = root->left; + root->left = invertTree(root->right); + root->right = invertTree(tmp); + return root; +}