val [ ] is for storing maximum profit for each weight wt [ ] is for storing weights n number of item W maximum capacity of bag dp [ W + 1 ] to store final result
int KnapSack ( int val [ ] , int wt [ ] , int n , int W ) {