Expedia Senior Software Engineer, Technical Screen

I got help from the previous experience articles here. So I left mine, too.

After the initial call with a recruiter, I got scheduled with an engineer.

I had 2 problems. First is merging intervals. Given intervals of [start_time, end_time], I need to merge overlapping intervals and return a new array of merged intervals. If there are no overlapping intervals, then I need to return an array of one interval which covers all given intervals.

I guess it should be easy for youguys, too. I passed this quickly and answered time complexity.

Second one was harder than the first one. I think it is because I sorted in a wrong field. I was given an array of stock trading logs: [buy_time, sell_time, profit]

Given the logs, I can choose trades which don't overlap. For example

0: [1, 3, 20]
1: [2, 4, 10]
2: [3, 5, 10]
  • 0 and 2 are not overlapping. sell_time and buy_time can be equal because as soon as sell on day 3, I can buy a stock on day 3 again.
  • 0 and 1 are definitely overlapping.

So you need to choose non-overlapping trades that sum up a maximum profit.

I found a slightly better than brute-force algorithm. But because of my binary search method's bug, I couldn't pass one of 3 test cases. Once 60 minutes was done, the engineer asked what the time complexity of my solution was and fortunately I answered a correct one.

Thanksfully I just got an invitation to next round. I hope you have good luck on your interviews.

Comments (2)