<awangdev>64. Minimum Path Sum_2.java
public int minPathSum(int[][] grid) {
        if (grid == null || grid.length == 0 || grid[0] == null || grid[0].length == 0) {
            return 0;
        }
        int m = grid.length;
        int n = grid[0].length;
        int[][] dp = new int[2][n];

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i == 0 && j == 0) {
                    dp[i % 2][j] = grid[i][j];
                    continue;
                } 
                int fromUp = i == 0 ? Integer.MAX_VALUE : dp[(i - 1) % 2][j];
                int fromLeft = j == 0 ? Integer.MAX_VALUE : dp[i % 2][j - 1];
                dp[i % 2][j] = Math.min(fromUp, fromLeft) + grid[i][j];
                
            }
        }
        
        return dp[(m - 1) % 2][n - 1];
    }
public int sample_funcname ( int [ ] [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) {
    return 0 ;
  }
  int var_4 = var_0 . length ;
  int var_5 = var_0 [ 0 ] . length ;
  int [ ] [ ] var_7 = new int [ 2 ] [ var_5 ] ;
  for ( int var_8 = 0 ;
  var_8 < var_4 ;
  var_8 ++ ) {
    for ( int var_9 = 0 ;
    var_9 < var_5 ;
    var_9 ++ ) {
      if ( var_8 == 0 && var_9 == 0 ) {
        var_7 [ var_8 % 2 ] [ var_9 ] = var_0 [ var_8 ] [ var_9 ] ;
        continue ;
      }
      int var_13 = var_8 == 0 ? Integer . MAX_VALUE : var_7 [ ( var_8 - 1 ) % 2 ] [ var_9 ] ;
      int var_14 = var_9 == 0 ? Integer . MAX_VALUE : var_7 [ var_8 % 2 ] [ var_9 - 1 ] ;
      var_7 [ var_8 % 2 ] [ var_9 ] = Math . min ( var_13 , var_14 ) + var_0 [ var_8 ] [ var_9 ] ;
    }
  }
  return var_7 [ ( var_4 - 1 ) % 2 ] [ var_5 - 1 ] ;
}
