LeetCode: Flatten Binary Tree to Linked List
摘要:
Given a binary tree, flatten it to a linked list in-place我的想法是,先将左子树flatten,然后右子树flatten,然后将左子树的结果移到root.right,然后将右子树接在左子树后面。但是总是超时。 1 public static void flatten(TreeNode root) { 2 if (root == null) return; 3 TreeNode left = root.left; 4 TreeNode right = root.right; 5 ... 阅读全文
posted @ 2014-02-10 05:37 longhorn 阅读(210) 评论(0) 推荐(0) 编辑