Java program for the above approach
import java . util . * ; class GFG { static int dp [ ] [ ] [ ] = new int [ 50 ] [ 10 ] [ 10 ] ; static void initialize ( ) { for ( int i = 0 ; i < 50 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { dp [ i ] [ j ] [ k ] = - 1 ; } } } }