<gouthampradhan>dynamic_programming_StoneGameIV_1.java
private int dp(int n, int p, int[] perfectSquares, int[] DP) {
    if (n == 0) return 1;
    else if (DP[n] != 0) return DP[n];
    else {
      int result = 1;
      for (int sq : perfectSquares) {
        if (n < sq) break;
        int r = dp(n - sq, ((p + 1) % 2), perfectSquares, DP);
        if (r == 1) {
          result = 2;
          break;
        }
      }
      DP[n] = result;
      return result;
    }
  }
private int sample_funcname ( int n , int p , int [ ] perfectSquares , int [ ] DP ) {
  if ( n == 0 ) return 1 ;
  else if ( DP [ n ] != 0 ) return DP [ n ] ;
  else {
    int result = 1 ;
    for ( int sq : perfectSquares ) {
      if ( n < sq ) break ;
      int r = dp ( n - sq , ( ( p + 1 ) % 2 ) , perfectSquares , DP ) ;
      if ( r == 1 ) {
        result = 2 ;
        break ;
      }
    }
    DP [ n ] = result ;
    return result ;
  }
}
