114. Flatten Binary Tree to Linked List
class Solution { public void flatten(TreeNode root) { TreeNode cur=root, pre=null; while(cur!=null) { if(cur.left!=null) { pre=cur.left; while(pre.right!=null) pre=pre.right; pre.right=cur.right; cur.right=cur.left; cur.left=null; } cur=cur.right; } } }