Maximum Profit Trades
Programming Interview
Questions
Maximum Profit Trades
You are given a list of daily stock prices where prices[i] is the price of a given stock on the i-th day.
Once you have bought, you must sell in order to buy again. You cannot short sell (i.e. sell and go into negative holdings).
Write a function maximum_profit(prices) to return the maximum profit you can achieve.
Input:
- prices: A list of numbers, denoting a stock price over time.
Output: The value gained from all maximum profit trades.
Your solution should run in Linear time O(n).
Tests - Login / Sign up to submit your code!
Efficiency
Test Case 1
Test Case 2
Test Case 3
Test Case 4
Test Case 5
Test Case 6
Test Case 7
Test Case 8
Test Case 9
Test Case 10
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results
Submit to See Results