上一页 1 2 3 4 5 6 7 ··· 13 下一页
摘要: public class Solution { public TreeNode buildTree(int[] preorder, int[] inorder) { int length = preorder.length; if (length == 0) { ... 阅读全文
posted @ 2015-12-06 05:19 Weizheng_Love_Coding 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 用了treemap来维护左右关系,其实也可以不用,记录一个min的index就好。public class Solution { public List> verticalOrder(TreeNode root) { List> result = new ArrayList>()... 阅读全文
posted @ 2015-12-06 03:04 Weizheng_Love_Coding 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 这个题之前做过,实在没想出什么好方法,今天突然发现这个完全就是个有环链表找开始进入环的题目,真是相当精巧public class Solution { public int findDuplicate(int[] nums) { int slow = 0; int ... 阅读全文
posted @ 2015-12-05 14:31 Weizheng_Love_Coding 阅读(111) 评论(0) 推荐(0) 编辑
摘要: class MyStack { // Push element x onto stack. Queue queue = new LinkedList(); public void push(int x) { Queue q = new LinkedList(); ... 阅读全文
posted @ 2015-12-05 13:34 Weizheng_Love_Coding 阅读(118) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public TreeNode invertTree(TreeNode root) { if (root == null) { return root; } TreeNode tmp... 阅读全文
posted @ 2015-12-05 13:29 Weizheng_Love_Coding 阅读(82) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int area = (C - A) * (D - B) + (G -... 阅读全文
posted @ 2015-12-05 13:25 Weizheng_Love_Coding 阅读(88) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public TreeNode buildTree(int[] inorder, int[] postorder) { return helper(inorder, postorder, 0, inorder.length - 1,... 阅读全文
posted @ 2015-12-05 09:49 Weizheng_Love_Coding 阅读(149) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public String largestNumber(int[] nums) { int length = nums.length; Queue queue = new PriorityQueue(length, n... 阅读全文
posted @ 2015-12-05 09:19 Weizheng_Love_Coding 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 主要是一下步骤1.delete space in front of str2.check if str startsWith other characters3.check if str is positive4.check the end of str5.check if overflowpubl... 阅读全文
posted @ 2015-12-05 08:39 Weizheng_Love_Coding 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 第一个是普通二叉树,第二个是bstpublic class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if (root == null) { ... 阅读全文
posted @ 2015-12-05 08:00 Weizheng_Love_Coding 阅读(123) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 13 下一页