Stores overlapping subproblems
int [ ] [ ] dp = new int [ N + 1 ] [ total ] ; for ( int [ ] k : dp ) Arrays . fill ( k , - 1 ) ; System . out . println ( smallestLeft ( arr , total , 0 , N , dp ) ) ; }