text: Driver code
code: public static void Main ( String [ ] args ) { int A = - 5 , B = 7 ; int [ ] treasure = { 4 , 8 , 2 , 9 } ; int [ ] color = { 2 , 2 , 6 , 2 } ; int n = color . Length ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) dp [ i , j ] = - 1 ; Console . Write ( MaxProfit ( treasure , color , n , 0 , 0 , A , B ) ) ; } }