Jatin is a college student and he got his first salary from an internship. his plan is to buy one stock on a particular day and then sell it on another day. He can trade (buy & sell) the stock only once. he has one time use magic spell which he used to get the stock prices N future consecutive days. based on this information and his strategy determine the maximum profit he can make. in the given list of price, the price of stock on the ith day is denoted by prices[i]. If there is no profit that can be achieved , return 0.
INPUT -7 1 5 3 6 4
OUTPUT- 5
INPUT- 1 11 13 21 19
OUTPUT- 20
Comments
Leave a comment