/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
void dfs(TreeNode* T, TreeNode* &pre, TreeNode* &NT)
{
if(T == nullptr) return;
dfs(T->left, pre, NT);
if(pre != nullptr) pre->right = T;
else NT = T;
T->left = nullptr;
pre = T;
dfs(T->right, pre, NT);
}
TreeNode* increasingBST(TreeNode* root) {
TreeNode* pre = nullptr;
TreeNode* NT = nullptr;
dfs(root, pre, NT);
pre->right = nullptr;
return NT;
}
};
自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。