aboutsummaryrefslogtreecommitdiff
path: root/other/invert_binary_tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/invert_binary_tree.cpp')
-rw-r--r--other/invert_binary_tree.cpp26
1 files changed, 0 insertions, 26 deletions
diff --git a/other/invert_binary_tree.cpp b/other/invert_binary_tree.cpp
deleted file mode 100644
index e8f0585..0000000
--- a/other/invert_binary_tree.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-// 226. Invert Binary Tree
-#include "leetcode.h"
-
-// given 'root' of binary tree, invert the tree and return its root
-
-class Solution {
-public:
- TreeNode *invertTree(TreeNode *root) {
- if (root == nullptr)
- return root;
- queue<TreeNode *> q;
- q.push(root);
- while (!q.empty()) {
- TreeNode *node = q.front();
- q.pop();
- if (node->left != nullptr)
- q.push(node->left);
- if (node->right != nullptr)
- q.push(node->right);
- TreeNode *tmp = node->left;
- node->left = node->right;
- node->right = tmp;
- }
- return root;
- }
-};