Initialize the memorization table
int [ ] [ ] memo = new int [ nums . length + 1 ] [ 2 * sum + 1 ] ; for ( int [ ] m : memo ) { Arrays . fill ( m , Integer . MIN_VALUE ) ; } return dfs ( memo , nums , S , 0 , 0 , sum ) ; }