comefrom: <gouthampradhan>dynamic_programming_CherryPickup_1.java
code: private int dp(int N, int r1, int c1, int c2, int[][][] DP, int[][] grid) {
      int r2 = r1 + (c1 - c2);
      if (r1 >= N || c1 >= N || c2 >= N || r2 >= N || grid[r1][c1] == -1 || grid[r2][c2] == -1)
        return Integer.MIN_VALUE;
      else if (DP[r1][c1][c2] != -1) return DP[r1][c1][c2];
      else if (r1 == N - 1 && c1 == N - 1) return grid[N - 1][N - 1];
      else {
        int max = (c1 == c2) ? grid[r1][c1] : (grid[r1][c1] + grid[r2][c2]);
        max +=
            Math.max(
                Math.max(
                    Math.max(dp(N, r1 + 1, c1, c2, DP, grid), dp(N, r1 + 1, c1, c2 + 1, DP, grid)),
                    dp(N, r1, c1 + 1, c2, DP, grid)),
                dp(N, r1, c1 + 1, c2 + 1, DP, grid));
        DP[r1][c1][c2] = max;
        return max;
      }
    }
masked: private int sample_funcname ( int N , int r1 , int c1 , int c2 , int [ ] [ ] [ ] DP , int [ ] [ ] grid ) {
    int r2 = r1 + ( c1 - c2 ) ;
    if ( r1 >= N || c1 >= N || c2 >= N || r2 >= N || grid [ r1 ] [ c1 ] == - 1 || grid [ r2 ] [ c2 ] == - 1 ) return Integer . MIN_VALUE ;
    else if ( DP [ r1 ] [ c1 ] [ c2 ] != - 1 ) return DP [ r1 ] [ c1 ] [ c2 ] ;
    else if ( r1 == N - 1 && c1 == N - 1 ) return grid [ N - 1 ] [ N - 1 ] ;
    else {
      int max = ( c1 == c2 ) ? grid [ r1 ] [ c1 ] : ( grid [ r1 ] [ c1 ] + grid [ r2 ] [ c2 ] ) ;
      max += Math . max ( Math . max ( Math . max ( dp ( N , r1 + 1 , c1 , c2 , DP , grid ) , dp ( N , r1 + 1 , c1 , c2 + 1 , DP , grid ) ) , dp ( N , r1 , c1 + 1 , c2 , DP , grid ) ) , dp ( N , r1 , c1 + 1 , c2 + 1 , DP , grid ) ) ;
      DP [ r1 ] [ c1 ] [ c2 ] = max ;
      return max ;
    }
  }
  