• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
April 22, 2022 |10.0K Views
Stock buy and sell | SDE Sheet | Arrays
  Share  7 Likes
Description
Discussion

In this video we will see when the cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days. Example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can be earned by buying on day 0 and selling on day 3. Again, buy on day 4 and sell on day 6. If the given array of prices is sorted in decreasing order, then profit cannot be earned at all. Check out the video to see how we implement this!! Practice Problem: https://practice.geeksforgeeks.org/problems/stock-buy-and-sell-1587115621/1 Article: https://www.geeksforgeeks.org/stock-buy-sell/ SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More