knakul853

Untitled

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