摘要:
class Solution { public int[] findOrder(int numCourses, int[][] prerequisites) { if(numCourses == 0) { return new int[0]; } Map> dependencies = new Ha... 阅读全文
摘要:
/** * Definition for binary tree with next pointer. * public class TreeLinkNode { * int val; * TreeLinkNode left, right, next; * TreeLinkNode(int x) { val = x; } * } */ public clas... 阅读全文
摘要:
class Solution { public int mySqrt(int x) { if (x 1) { int mid = start + (end - start)/2; if (mid == x / mid) { return mid; } else if ... 阅读全文
摘要:
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { pub... 阅读全文
摘要:
class Solution { public boolean isValid(String s) { if (s.length() % 2 == 1) { return false; } Stack stack = new Stack(); for (char c : s.toCh... 阅读全文
摘要:
class Solution { public int findTargetSumWays(int[] nums, int S) { if (nums.length == 0) { return 0; } int sum = 0; for (int num : nums) { ... 阅读全文
摘要:
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.... 阅读全文
摘要:
class Solution { Map startIndex; Map lengths; Random random; public Solution(int[] nums) { random = new Random(); startIndex = new HashMap(); lengths = new Ha... 阅读全文