-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path114.cpp
More file actions
31 lines (28 loc) · 757 Bytes
/
114.cpp
File metadata and controls
31 lines (28 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//coding:utf-8
/***********************************************************
Program: Flatten Binary Tree to Linked List
Description:
Shanbo Cheng: cshanbo@gmail.com
Date: 2016-08-11 16:25:36
Last modified: 2016-08-11 16:40:30
GCC version: 4.9.3
***********************************************************/
#include "misc.h"
class Solution {
public:
void flatten(TreeNode *root) {
if(!root)
return;
flatten(root->left);
flatten(root->right);
TreeNode* temp = root->right;
if(root->left) {
root->right = root->left;
root->left = NULL;
while(root->right)
root = root->right;
root->right = temp;
}
}
};
int main() {}