Palantir Technologies Interview Question
109 Interview Reviews |
Back to all Palantir Technologies Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Engineering at Palantir Technologies:
You are given the price of a stock in a period of time. Find the days to buy and sell the stock for one time to get the most profit.
See more for this Palantir Technologies Software Engineering Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (3)
1) if array[i] < working_min, working_min = array[i]
2) if array[i] - working_min > working_maxdiff, then working_maxdiff = array[i] - working_min
If you are allowed to short, all you need is to simultaneously search for the min and max. Subtract them at the end.
Helpful Answer?
Yes |
No
Inappropriate?
Creating array is O(n) and then finding max sum using dynamic programming is O(n).
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up
0 of 0 people found this helpful
by AMH:
Buy[0] = -V[0], Sell[0] = 0
Max operation can be linearized by storing a value.