static int minSteps ( int i , int j , int arr [ ] [ ] ) {
  if ( i == n - 1 && j == n - 1 ) {
    return 0 ;
  }
  if ( i > n - 1 || j > n - 1 ) {
    return 9999999 ;
  }
  if ( v [ i ] [ j ] == 1 ) {
    return dp [ i ] [ j ] ;
  }
  v [ i ] [ j ] = 1 ;
  dp [ i ] [ j ] = 1 + Math . min ( minSteps ( i + arr [ i ] [ j ] , j , arr ) , minSteps ( i , j + arr [ i ] [ j ] , arr ) ) ;
  return dp [ i ] [ j ] ;
}

static int minSteps ( int i , int j , int arr [ ] [ ] ) { if ( i == n - 1 && j == n - 1 ) { return 0 ; } if ( i > n - 1 || j > n - 1 ) { return 9999999 ; } if ( v [ i ] [ j ] == 1 ) { return dp [ i ] [ j ] ; } v [ i ] [ j ] = 1 ; dp [ i ] [ j ] = 1 + Math . min ( minSteps ( i + arr [ i ] [ j ] , j , arr ) , minSteps ( i , j + arr [ i ] [ j ] , arr ) ) ; return dp [ i ] [ j ] ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (block (return_statement (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (block (return_statement (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (decimal_integer_literal) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))) (identifier) (identifier))) (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))) (identifier)))))))) (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))))