摘要: https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/discuss/35476/Share-my-JAVA-solution-1ms-very-short-and-concise. 阅读全文
posted @ 2018-09-20 10:29 jasoncool1 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public TreeNode sortedArrayToBST(int[] nums) { 3 int size = nums.length; 4 return helper(nums, 0, size - 1); 5 6 } 7 8 public Tr... 阅读全文
posted @ 2018-09-20 07:32 jasoncool1 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public List> levelOrderBottom(TreeNode root) { 3 Queue queue = new LinkedList(); 4 List> res = new ArrayList(); 5 if(root == null) return res; 6... 阅读全文
posted @ 2018-09-20 06:56 jasoncool1 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public TreeNode buildTree(int[] inorder, int[] postorder) { 3 return helper(postorder.length-1, 0, inorder.length - 1, inorder, postorder); 4 5 } 6... 阅读全文
posted @ 2018-09-20 06:44 jasoncool1 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1 //New 用一个记录queue.size()就可以 2 class Solution { 3 public List> zigzagLevelOrder(TreeNode root) { 4 List> res = new ArrayList(); 5 if(root == null) return res; 6 Queu... 阅读全文
posted @ 2018-09-20 05:54 jasoncool1 阅读(139) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/symmetric-tree/discuss/166375/Java-Accepted-very-simple-solution 阅读全文
posted @ 2018-09-20 04:28 jasoncool1 阅读(115) 评论(0) 推荐(0) 编辑