leetcode/src/s0226_invert_binary_tree.cpp

10 lines
246 B
C++
Raw Normal View History

2023-01-30 12:18:01 +00:00
#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;
}