摘要:        
不难。就是比如到了[0, 1, 3, 2]时,下一组就要[4+2, 3+2, 1+2, 0+2]。但是当时没有做到ans.add(0)一开始初始化(而是只放在n==0的判断block内了),所以runtime error了。看了半天看出来了。public class Solution { public ArrayList grayCode(int n) { // Start typing your Java solution below // DO NOT write main() function ArrayList ans = new Arr...    阅读全文
posted @ 2013-08-13 21:17
阿牧遥
阅读(165)
评论(0)
推荐(0)
        
            
        
        
摘要:        
动态规划。再最左和最上加了0的一行一列。但是一开始忘了把mx[1][1]设成1了。public class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { // Start typing your Java solution below // DO NOT write main() function int m = obstacleGrid.length; if (m == 0) return 0; int n = obsta...    阅读全文
posted @ 2013-08-13 20:49
阿牧遥
阅读(173)
评论(0)
推荐(0)
        
            
        
        
摘要:        
动态规划。就是要注意第0行和第0列的初始化。 public class Solution { public int minPathSum(int[][] grid) { // Start typing your Java solution below // DO NOT write main() f    阅读全文
posted @ 2013-08-13 20:38
阿牧遥
阅读(148)
评论(0)
推荐(0)
        
 
                     
                    
                 
                    
                
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号