knakul853

Untitled

Jun 10th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1.  
  2. /**
  3.  knakul853
  4.  */
  5. class Solution {
  6. public:
  7.     TreeNode* invertTree(TreeNode* root) {
  8.        
  9.         if(!root) return NULL;
  10.        
  11.         TreeNode* temp = root->left;
  12.         root->left = root->right;
  13.         root->right = temp;
  14.        
  15.         invertTree(root->left);
  16.         invertTree(root->right);
  17.         return root;
  18.        
  19.     }
  20. };
Add Comment
Please, Sign In to add comment