Company: Tech Mahindra_6oct
Difficulty: medium
Maximize Sales Days Problem Description A travelling salesperson works in N towns, numbered 1 to N . Each working day, the salesperson sells products in exactly one town. The towns chosen on any two successive working days must be different. Town i can be chosen at most countTown[i-1] times in total. A town does not have to use up its limit: it may be chosen fewer times, or not at all. The working days form one consecutive run starting on day 1 . (inferred -- the source does not say this directly; the source example (Example 1, answer 11 rather than 12 ) is only correct under this reading, since a day off would let every visit be used.) Determine the maximum number of days the salesperson can work while following all of these rules. Complete the function maxDaysToWork(countTown) , which returns this maximum. Input Format The first line contains a single integer N , the number of towns. The second line contains N space-separated integers countTown[0] through countTown[N-1] , where count