摘要: public static String printBin(double num) { StringBuffer str = new StringBuffer(); str.append('0'); str.appe... 阅读全文
posted @ 2015-12-24 16:06 创业-李春跃-增长黑客 阅读(219) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public static int binInsert(int n, int m, int i, int j) { // write code here// return n | (m << i); in... 阅读全文
posted @ 2015-12-24 12:46 创业-李春跃-增长黑客 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 因为,没有重复值,所以只需要做一个标记就OK了。public class Successor { static boolean flag = false; static int result = 0; public int findSucc(TreeNode root, int... 阅读全文
posted @ 2015-12-22 22:21 创业-李春跃-增长黑客 阅读(183) 评论(0) 推荐(0) 编辑
摘要: public boolean checkBST(TreeNode root) { return isBST(root, Long.MIN_VALUE, Long.MAX_VALUE); } public boolean isBST(TreeNode root, lo... 阅读全文
posted @ 2015-12-22 20:46 创业-李春跃-增长黑客 阅读(199) 评论(0) 推荐(0) 编辑
摘要: public class TreeLevel { public ListNode getTreeLevel(TreeNode root, int dep) { // write code here List result = new ArrayList(); ... 阅读全文
posted @ 2015-12-22 20:36 创业-李春跃-增长黑客 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 1,并没有把高度和建表结合了。而是最后才算。下一次可以想想怎么结合到一块去。1,建表(参考自书本) private static TreeNode createMinimalBST(int arr[], int start, int end){ if (end < start) ... 阅读全文
posted @ 2015-12-22 17:39 创业-李春跃-增长黑客 阅读(588) 评论(0) 推荐(0) 编辑
摘要: //这道题AC了,但是并不确定是否完全正确。此外要注意因为是有向图,所以既要检查a到b,还要检查b到apublic class Path { public boolean checkPath(UndirectedGraphNode a, UndirectedGraphNode b) { ... 阅读全文
posted @ 2015-12-22 16:06 创业-李春跃-增长黑客 阅读(215) 评论(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 创业-李春跃-增长黑客 阅读(165) 评论(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 创业-李春跃-增长黑客 阅读(270) 评论(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 创业-李春跃-增长黑客 阅读(139) 评论(0) 推荐(0) 编辑