Question: python3thank you Question 4: Maximum Profit for Stock (4 points) Suppose you have stock price history, and you are allowed to buy only once and
Question 4: Maximum Profit for Stock (4 points) Suppose you have stock price history, and you are allowed to buy only once and sell only once. Write a the maximum profit you can make. There is no need to buy if no profit is possible. tit(prices) that finds For example, if you have the prices -Is. 0.2. 11, 201 which equals to 18 , the maximum beneft would be buying at the price 2 and seling at the pice In [ def max_prof it (prices)I # your code here ]' max-profit([0,-101)--o In [
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
