WebRound 1-question 1 - given an array of stock prices for n days.Write an algorithm to maximize the profit of a customer such that he can buy and sell only once. -Question 2 … Web15 sep. 2024 · Output. The Maximum profit is 4196007. A more effective solution is based on finding the maximum profit from them by finding the maximum profit for each trade. This can be done by finding local minima and maxima for the trade days. Local minima are those days where the stock price is less than both its previous and next day.
Maximum profit after buying and selling the stocks in C
Web1. Input: Price [] = {2,32,73,42,8, 5,50,87} Output: 153. Explanation: First Transaction – Trader buys shares at price 2 and sells at price 73 because, at this price, the maximum … WebThus, a person can purchase a stock on the first day, and can sell on the fourth day. Thus, the profit becomes 155 - 50 = 105. Again, the stock can be purchased on the fifth day and should be sold on the seventh day. Thus, the profit becomes 347 - 20 = 327, and the total profit becomes 105 + 327 = 432 that is the maximum profit earned. shrinking lotion
Round 1-question 1 - given an CareerCup
Web1. Input: Price [] = {2,32,73,42,8, 5,50,87} Output: 153. Explanation: First Transaction – Trader buys shares at price 2 and sells at price 73 because, at this price, the maximum profit is 71. Second Transaction – Similarly, Trader buys again at price 5 (which is the least price next after selling at price 73 in the first transaction) and ... WebQuestion 2 : Repeating Characters. Problem Statement – Codu is given a string and he thinks the letters that are repeated do have more power. He gathers only the repeating … WebBuy on day 1 and sell on day 2. Buy on day 3 and sell on day 5. Buy on day 7 and sell on day 8. Total profit earned is 10. The time complexity of the above solution is O (n) and doesn’t require any extra space, where n is the total number of given days. Rate this post. shrinking leather wallet