Driver Code
var n = 5 ; var profit = [ 2 , 7 , 1 , 5 , 3 ] ; var weight = [ 2 , 5 , 2 , 3 , 4 ] ; var max_weight = 8 ; var max_element = 2 ; document . write ( maxProfit ( profit , weight , n , max_weight , max_element ) + " " ) ;