摘要:
public class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { int row = obstacleGrid.length; if (row == 0) { ... 阅读全文
posted @ 2015-12-04 16:42
Weizheng_Love_Coding
阅读(149)
评论(0)
推荐(0)
摘要:
public class Solution { public void rotate(int[][] matrix) { int n = matrix.length; int count = (n + 1) / 2; for (int i = 0; i... 阅读全文
posted @ 2015-12-04 14:30
Weizheng_Love_Coding
阅读(114)
评论(0)
推荐(0)
摘要:
判断四个数是否可能通过加减乘得到二十四, 可以使用括号,思路极其像Expression Add Operators, 区别是在处理乘号的时候,一种是没有括号的,和Expression Add Operators一样,一种是带有括号的,其实就是把乘号当作加号来计算public class Soluti... 阅读全文
posted @ 2015-12-04 12:45
Weizheng_Love_Coding
阅读(187)
评论(0)
推荐(0)
摘要:
dp的方法比较简单就不写了。这里用分治法,对与一个数组,最大的子区间可以在left 到 mid这一段, 也可能划过mid, 也可能在mid 到 right, 所以分别求这三段,取最大的结果。求左右段最大的时候才用分治的想法。算法复杂度为o(nlogn)public class Solution { ... 阅读全文
posted @ 2015-12-04 11:53
Weizheng_Love_Coding
阅读(149)
评论(0)
推荐(0)
摘要:
两种解法,第一个是利用了前序遍历递增的特点public class Solution { long count = Long.MIN_VALUE; public boolean isValidBST(TreeNode root) { if (root == null) { ... 阅读全文
posted @ 2015-12-04 09:42
Weizheng_Love_Coding
阅读(118)
评论(0)
推荐(0)
摘要:
1 public class Solution { 2 public List> zigzagLevelOrder(TreeNode root) { 3 List> result = new ArrayList>(); 4 if (root == null)... 阅读全文
posted @ 2015-12-04 09:25
Weizheng_Love_Coding
阅读(121)
评论(0)
推荐(0)
摘要:
第三次写了,一遍过/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(i... 阅读全文
posted @ 2015-12-04 09:08
Weizheng_Love_Coding
阅读(140)
评论(0)
推荐(0)
摘要:
public class Solution { public int[] twoSum(int[] numbers, int target) { int left = 0; int right = numbers.length - 1; while (... 阅读全文
posted @ 2015-12-04 08:03
Weizheng_Love_Coding
阅读(114)
评论(0)
推荐(0)
摘要:
public class Solution { public int minSubArrayLen(int s, int[] nums) { int p1 = 0; int p2 = 0; int length = nums.length; ... 阅读全文
posted @ 2015-12-04 07:34
Weizheng_Love_Coding
阅读(113)
评论(0)
推荐(0)
摘要:
public class Solution { private int result = Integer.MIN_VALUE; public int maxPathSum(TreeNode root) { helper(root); return result... 阅读全文
posted @ 2015-12-04 07:34
Weizheng_Love_Coding
阅读(106)
评论(0)
推荐(0)
摘要:
第一个是递归方法,第二个是非递归方法public class Solution { public boolean isSymmetric(TreeNode root) { if (root == null) { return true; } ... 阅读全文
posted @ 2015-12-04 07:26
Weizheng_Love_Coding
阅读(114)
评论(0)
推荐(0)

浙公网安备 33010602011771号