We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Stock Maximize
Stock Maximize
Sort by
recency
|
365 Discussions
|
Please Login in order to post a comment
lol I overcomplicated this problem for some reason
Just go from end to beginning
Not a DP problem. Solution is just to iterate backwards. If our current price is greater than the max price, update the max price. If it is smaller, then there is profit to be made - and that profit is the difference between the current price and max price (as we would offload all shares on the max price day).
Here is my solution in java, javascript, python, C , C++, Csharp HackerRank Stock Maximize Problem Solution