<gouthampradhan>dynamic_programming_OddEvenJump_1.java
private int dp(int[] A, int i, int[][] next, int[][] possible, int oddOrEven) {
    if (i == A.length - 1) return 1;
    else if (possible[oddOrEven][i] == 1 || possible[oddOrEven][i] == 0) {
      return possible[oddOrEven][i];
    } else {
      int nextPos = oddOrEven == 0 ? next[0][i] : next[1][i];
      if (nextPos == -1) {
        possible[oddOrEven][i] = 0;
        return possible[oddOrEven][i];
      } else {
        possible[oddOrEven][i] = dp(A, nextPos, next, possible, ((oddOrEven + 1) % 2));
        return possible[oddOrEven][i];
      }
    }
  }
private int sample_funcname ( int [ ] A , int i , int [ ] [ ] next , int [ ] [ ] possible , int oddOrEven ) {
  if ( i == A . length - 1 ) return 1 ;
  else if ( possible [ oddOrEven ] [ i ] == 1 || possible [ oddOrEven ] [ i ] == 0 ) {
    return possible [ oddOrEven ] [ i ] ;
  }
  else {
    int nextPos = oddOrEven == 0 ? next [ 0 ] [ i ] : next [ 1 ] [ i ] ;
    if ( nextPos == - 1 ) {
      possible [ oddOrEven ] [ i ] = 0 ;
      return possible [ oddOrEven ] [ i ] ;
    }
    else {
      possible [ oddOrEven ] [ i ] = dp ( A , nextPos , next , possible , ( ( oddOrEven + 1 ) % 2 ) ) ;
      return possible [ oddOrEven ] [ i ] ;
    }
  }
}
