上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 36 下一页
摘要: class Solution { public int[] findOrder(int numCourses, int[][] prerequisites) { if(numCourses == 0) { return new int[0]; } Map> dependencies = new Ha... 阅读全文
posted @ 2017-08-31 15:49 keepshuatishuati 阅读(139) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for binary tree with next pointer. * public class TreeLinkNode { * int val; * TreeLinkNode left, right, next; * TreeLinkNode(int x) { val = x; } * } */ public clas... 阅读全文
posted @ 2017-08-31 15:08 keepshuatishuati 阅读(88) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int mySqrt(int x) { if (x 1) { int mid = start + (end - start)/2; if (mid == x / mid) { return mid; } else if ... 阅读全文
posted @ 2017-08-31 14:58 keepshuatishuati 阅读(85) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { pub... 阅读全文
posted @ 2017-08-31 14:49 keepshuatishuati 阅读(77) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean isValid(String s) { if (s.length() % 2 == 1) { return false; } Stack stack = new Stack(); for (char c : s.toCh... 阅读全文
posted @ 2017-08-31 14:41 keepshuatishuati 阅读(73) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int findTargetSumWays(int[] nums, int S) { if (nums.length == 0) { return 0; } int sum = 0; for (int num : nums) { ... 阅读全文
posted @ 2017-08-31 14:30 keepshuatishuati 阅读(80) 评论(0) 推荐(0) 编辑
摘要: class Solution { public double myPow(double x, int n) { if (x == 0.0) { return x; } double sign = n > 0 ? 1.0 : -1.0; long nn = Math.abs(Long.... 阅读全文
posted @ 2017-08-31 13:35 keepshuatishuati 阅读(59) 评论(0) 推荐(0) 编辑
摘要: class Solution { Map startIndex; Map lengths; Random random; public Solution(int[] nums) { random = new Random(); startIndex = new HashMap(); lengths = new Ha... 阅读全文
posted @ 2017-08-31 13:26 keepshuatishuati 阅读(92) 评论(0) 推荐(0) 编辑
摘要: Because of lots dups in dict, better to use hash set to filter it out. 阅读全文
posted @ 2017-08-30 15:43 keepshuatishuati 阅读(108) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean increasingTriplet(int[] nums) { if (nums.length < 3) { return false; } int small = Integer.MAX_VALUE; int middle = Inte... 阅读全文
posted @ 2017-08-30 14:44 keepshuatishuati 阅读(69) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 36 下一页