摘要:
class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { for(int i=0;i=0?1:0; for(int i=0;i=0) obstacleGrid[i][j]+=(i>0&&obstacleGrid[i-1][... 阅读全文
摘要:
class Solution { public int uniquePaths(int m, int n) { int[][] dp=new int[m][n]; dp[0][0]=1; for(int i=0;i0?dp[i-1][j]:0)+(j>0?dp[i][j-1]:0); return dp[m-1][n-1];... 阅读全文
摘要:
class Solution { public ListNode rotateRight(ListNode head, int k) { ListNode preNode=new ListNode(0); preNode.next=head; ListNode p=preNode; int len=0; wh... 阅读全文
摘要:
Base on next permutation: 阅读全文
摘要:
class Solution { public int[][] generateMatrix(int n) { int[][] matrix=new int[n][n]; generateMatrix(0, 0, 0, n-1, n-1, matrix); return matrix; } private void gene... 阅读全文
摘要:
class Solution { public List insert(List intervals, Interval newInterval) { int idx=0; while(idx res=new ArrayList(); int start=intervals.get(0).start; int end=int... 阅读全文
摘要:
class Solution { public List merge(List intervals) { List res=new ArrayList(); if(intervals.size()==0) return res; Collections.sort(intervals, (a,b)->a.start-b... 阅读全文
摘要:
public class Solution { public boolean canJump(int[] nums) { int maxDistance=0; for(int i=0;i=nums.length-1) return true; } return false; ... 阅读全文
摘要:
public class Solution { public List spiralOrder(int[][] matrix) { List res=new ArrayList(); if(matrix.length==0||matrix[0].length==0) return res; spiralOrder(0... 阅读全文
摘要:
class Solution { public int totalNQueens(int n) { int[][] board=new int[n][n]; return totalNQueens(0, board); } private int totalNQueens(int i, int[][] board) { ... 阅读全文