@@ -0,0 +1,1268 @@
+package me.wayne.leetcodetop100.binarytree;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport me.wayne.leetcodetop100.TreeNode;%0A%0A/**%0A * %E7%BB%99%E4%BD%A0%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%A0%B9%E7%BB%93%E7%82%B9 root %EF%BC%8C%E8%AF%B7%E4%BD%A0%E5%B0%86%E5%AE%83%E5%B1%95%E5%BC%80%E4%B8%BA%E4%B8%80%E4%B8%AA%E5%8D%95%E9%93%BE%E8%A1%A8%EF%BC%9A%0A * %3Cp%3E%0A * %E5%B1%95%E5%BC%80%E5%90%8E%E7%9A%84%E5%8D%95%E9%93%BE%E8%A1%A8%E5%BA%94%E8%AF%A5%E5%90%8C%E6%A0%B7%E4%BD%BF%E7%94%A8 TreeNode %EF%BC%8C%E5%85%B6%E4%B8%AD right %E5%AD%90%E6%8C%87%E9%92%88%E6%8C%87%E5%90%91%E9%93%BE%E8%A1%A8%E4%B8%AD%E4%B8%8B%E4%B8%80%E4%B8%AA%E7%BB%93%E7%82%B9%EF%BC%8C%E8%80%8C%E5%B7%A6%E5%AD%90%E6%8C%87%E9%92%88%E5%A7%8B%E7%BB%88%E4%B8%BA null %E3%80%82%0A * %E5%B1%95%E5%BC%80%E5%90%8E%E7%9A%84%E5%8D%95%E9%93%BE%E8%A1%A8%E5%BA%94%E8%AF%A5%E4%B8%8E%E4%BA%8C%E5%8F%89%E6%A0%91 %E5%85%88%E5%BA%8F%E9%81%8D%E5%8E%86 %E9%A1%BA%E5%BA%8F%E7%9B%B8%E5%90%8C%E3%80%82%0A * %3Cp%3E%0A * %E9%93%BE%E6%8E%A5%EF%BC%9Ahttps://leetcode-cn.com/problems/flatten-binary-tree-to-linked-list%0A */%0Apublic class LC114_Flatten %7B%0A%0A    public void flatten(TreeNode root) %7B%0A        List%3CTreeNode%3E list = traversal(root);%0A        for (int i = 0; i %3C list.size(); i++) %7B%0A            TreeNode cur = list.get(i);%0A            TreeNode next = null;%0A            if (i + 1 %3C list.size()) %7B%0A                next = list.get(i + 1);%0A            %7D%0A            cur.left = null;%0A            cur.right = next;%0A        %7D%0A    %7D%0A%0A    private List%3CTreeNode%3E traversal(TreeNode root) %7B%0A        List%3CTreeNode%3E list = new ArrayList%3C%3E();%0A        preTraversal(list, root);%0A        return list;%0A    %7D%0A%0A    private void preTraversal(List%3CTreeNode%3E list, TreeNode root) %7B%0A        if (root == null) %7B%0A            return;%0A        %7D%0A        list.add(root);%0A        if (root.left != null) %7B%0A            preTraversal(list, root.left);%0A        %7D%0A        if (root.right != null) %7B%0A            preTraversal(list, root.right);%0A        %7D%0A    %7D%0A%7D%0A

add LC114_Flatten