Question: Write python code for below question; Rakesh Junjunwala hired you to work in his investment firm. Observing the critical situation during the Covid pandemic he

Write python code for below question;

Write python code for below question; Rakesh Junjunwala hired you to work

Rakesh Junjunwala hired you to work in his investment firm. Observing the critical situation during the Covid pandemic he decided to invest in gold. As per his strategy, he purchased the gold when its price is less and sells it when the price is high. He wants to compare his profit with an optimal result. Thus he provided you a day-wise price of gold for N days. Now can you write a program to find all the days on which one can buy and sell the gold so that in between those days the profit is maximum? Your program should print 'No profit' if you are not getting any. Example: Input: # Number of days 42 224 # per day gold value (separated by white space) 5 Output: (3, 4) Explanation: We can buy gold on day 3( day count starting from 0), and sell it on the 4th day, which will give us a maximum profit of 2 units. Input 2: 4 2435 Output: (0, 1), (2,3) Explanation: Buy on day 0 and sell on day 1. Again buy on day 2 and sell on day 3. Total profit is (4-2) + (5-3) = 4 units. Input 3: 4 1111 Output: No Profit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!