上一页 1 ··· 9 10 11 12 13 14 15 下一页
摘要: public class TreeLevel { public ListNode getTreeLevel(TreeNode root, int dep) { // write code here List result = new ArrayList(); ... 阅读全文
posted @ 2015-12-22 20:36 仔细思考一切 阅读(216) 评论(0) 推荐(0)
摘要: 1,并没有把高度和建表结合了。而是最后才算。下一次可以想想怎么结合到一块去。1,建表(参考自书本) private static TreeNode createMinimalBST(int arr[], int start, int end){ if (end < start) ... 阅读全文
posted @ 2015-12-22 17:39 仔细思考一切 阅读(601) 评论(0) 推荐(0)
摘要: //这道题AC了,但是并不确定是否完全正确。此外要注意因为是有向图,所以既要检查a到b,还要检查b到apublic class Path { public boolean checkPath(UndirectedGraphNode a, UndirectedGraphNode b) { ... 阅读全文
posted @ 2015-12-22 16:06 仔细思考一切 阅读(220) 评论(0) 推荐(0)
摘要: //也就是把高度在递归过程中给一并算了。public class Balance { public static boolean checkBalance(TreeNode root, int[] dep){//java 里没有传地址if(null == root){dep[0] = 0;re... 阅读全文
posted @ 2015-12-22 14:22 仔细思考一切 阅读(182) 评论(0) 推荐(0)
摘要: 解答的思路:建立一个queue放狗,一个queue放猫。如下:import java.util.*;class Dog{ int time; int value; Dog(int a, int b){ time = a; value = b; }}... 阅读全文
posted @ 2015-12-21 22:38 仔细思考一切 阅读(277) 评论(0) 推荐(0)
摘要: 答,课本上的方法比较好。 public static Stack sort(Stack s) { Stack r = new Stack(); while(!s.isEmpty()) { int tmp = s.pop(); ... 阅读全文
posted @ 2015-12-21 22:09 仔细思考一切 阅读(147) 评论(0) 推荐(0)
摘要: 手写时候,别忘记import java.util.Stack;import java.util.Stack;class MyQueue { Stack s1 = new Stack(); Stack s2 = new Stack(); // Push element x to th... 阅读全文
posted @ 2015-12-21 11:03 仔细思考一切 阅读(136) 评论(0) 推荐(0)
摘要: 思路:注意一下别写错add还是removepublic class SetOfStacks { public static ArrayList> setOfStacks(int[][] ope, int size) { // write code here ... 阅读全文
posted @ 2015-12-20 13:25 仔细思考一切 阅读(161) 评论(0) 推荐(0)
摘要: //思路:入栈时不是最小值,永远都没机会成为最小值。import java.util.Stack;class MinStack { private Stack stack = new Stack(); private Stack minStack = new Stack(); p... 阅读全文
posted @ 2015-12-20 13:24 仔细思考一切 阅读(218) 评论(0) 推荐(0)
摘要: 1,就是把数组分成三份。 阅读全文
posted @ 2015-12-20 13:22 仔细思考一切 阅读(209) 评论(0) 推荐(0)
上一页 1 ··· 9 10 11 12 13 14 15 下一页