- 博客(10)
- 资源 (3)
- 收藏
- 关注
转载 Leetcode 138,Copy list with random nodes
public RandomListNode copyRandomList(RandomListNode head) { if(head==null) return null; HashMap map = new HashMap(); RandomListNode newhead = new RandomLis
2016-12-29 14:01:15 181
转载 Leetcode 113, Path Sum II
public void pathSumHelper(TreeNode root, int sum, List sumlist, List> pathlist){ if(root==null) return; sumlist.add(root.val); sum = sum-root.val; if(root
2016-12-28 11:31:27 191
原创 Leetcode 116, Populating Next Right Pointers in Each Node
public void connect(TreeLinkNode root) { if(root == null){ return; } if(root.left != null){ root.left.next = root.right; } if(root.right
2016-12-24 00:01:42 156
原创 Leetcode 98,Validate Binary Search Tree
private long min = Long.MIN_VALUE; public boolean isValidBST(TreeNode root) { if (root == null) return true; if (!isValidBST(root.left)){ return false;
2016-12-15 07:19:31 172
转载 Leetcode 132,Palindrome Partitioning 2
public int minCut(String s) { int len = s.length(); int[] D = new int[len + 1]; boolean[][] P = new boolean[len][len]; //the worst case is cutting by each char
2016-12-13 12:21:14 253
原创 Leetcode 213. House Robber II
public int rob(int[] nums) { if(nums==null||nums.length==0) return 0; if(nums.length==1){ return nums[0]; } int temp = nums[0]; nums[0] = 0; int a = helper(n
2016-12-13 05:43:21 293
原创 Leetcode 10, 44 Regular Expression Marching, Wildcard Matching
10, public boolean isMatch(String s, String p) { if (s == null || p == null) { return false; } int m = s.length(); int n = p.length();
2016-12-12 07:28:11 336
原创 Leetcode 97, Interleaving String
public boolean isInterleave(String s1, String s2, String s3) { if(s3.length() != s1.length() + s2.length()) { return false; } int m = s1.length();
2016-12-11 11:15:18 229
原创 Leetcode 512, Mouse in a maze
Rat in maze shortest path Given a 2 dimensional array with number 1s and 0s, 1 means wall, 0 means road, find the shortest path from 0 row 0 column to m row n column, if not possible return -1.
2016-12-11 08:06:11 499
原创 Leetcode 70, Climbing stair
DP写法: public int climbStairs(int n) { if(n == 0 || n == 1) return n; int [] dp = new int[n]; dp[0] = 1; dp[1] = 2; for(int i = 2; i< n
2016-12-11 07:27:19 280
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人