maximum profit given revenue in 2 cities and travel cost
Anonymous User
619

Given a traveling salesperson who travels back and forth between 2 cities A and B. Also given are pair of arrays - revA and revB of length n such that:
revA[i]= revenue that would be made by selling goods at city A on day i
revB[i]= revenue that would be made by selling goods at city B on day i
The salesperson can only sell goods in one city per day. At the end of the each day, you can choose to travel to another city but that will cost a constant amount of money (travelCost)
Hence Profit= Revenue- travelCost

Given these inputs, write a function that will return max profit attainable from some schedule in which each day is spent in of the two cities.
for eg.

revA[]= {3,7}
revB[]={5,4}
travelCost=2
maxProfit =10
[ first day in city B and second day in city A; (5 -2 +7 )]

Comments (5)