Advertisement
knakul853

Untitled

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