Initialize DP [ ] [ ] entries as - 1
for ( int i = 0 ; i <= count [ 0 ] ; ++ i ) for ( int j = 0 ; j < count [ 1 ] ; ++ j ) for ( int k = 0 ; k < count [ 2 ] ; ++ k ) DP [ i ] [ j ] [ k ] = -1 ; return length ( count [ 0 ] , count [ 1 ] , count [ 2 ] ) ; }