Facebook | Intern | Phone Interview
Anonymous User
1382

Here's a question I got yesterday from FB:

Given an array of two train ticket prices, what's the cost of the cheapest round trip you can take, given that the earliest you can return is the same day you leave? For example, if we have the list of leaving times D = [10, 11, 8, 9, 7] and a list of return times R = [8, 9, 9, 7, 8]. In this case, the answer is 15, since you can leave and return on the last day (leave for a price of 7, and return for a price of 8). You're guaranteed that D and R will be provided in a well-formed way (no need to check if the entries are valid ints, etc.), and that they have the same length.

Comments (3)