employer cover photo
employer logo
employer logo

Cohere Technologies

Is this your company?

Cohere Technologies interview question

“You have all of the prices for a given stock for the next year. You can buy once and sell once in that year. How do you determine when to buy and sell to maximize your profit?”

Interview Answers

Anonymous

9 Nov 2018

That answer does not work if the lowest price occurs _after_ the highest price. You have to evaluate the difference in price for each combination of days and find out which one results in the highest gain. You always assume that for whichever day you buy, the sell date will be _after_ that date. So you compare day 1 with days 2-365 and find the max gain for those combinations. Then you do the same for a buy on day 2, 3...etc. You'll end up with 364 max value date pairs. Now sort for the highest and use that combination for your best gain. Too bad it doesn't work that way in real life :)

1

Anonymous

10 May 2018

Buy when its at the lowest and sell when its at the highest.

Anonymous

13 May 2015

Declined

1