Google On Site | L4
Anonymous User
1811

Got a question in onsite which seems to be tricky.

A salesman travel between two cities A and B to sell its product. On a particular day, he can either choose to sell the product or travel to other city. He cannot travel and sell on same day.
We need to print the schedule of salesman for maximum profit earned.

For example:
Cost of selling product in city A: A = [23, 4, 5, 20]
Cost of selling product in city B: B = [21, 1, 10 100]

So max profit he can earn is by:
Day1: Sell in City A (A)
Day2: Travel to City B (T)
Day3: Sell in City B (B)
Day4: Sell in City B (B)

Hence the answer should be "ATBB"

Similar kind of problem with some addon https://leetcode.com/discuss/interview-question/762690/google-telephone-interview-coding-question.
We need to account for travel and print the max profit schedule as String.

How to approach this problem or any similar question available anywhere.

Comments (12)