9

Stock buy and sell | SDE Sheet | Arrays

 3 years ago
source link: https://www.geeksforgeeks.org/videos/stock-buy-and-sell-jchpzd/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Stock buy and sell
Stock buy and sell | SDE Sheet | Arrays
Video Player is loading.
Loaded: 0%
00:00
Remaining Time -11:45
  • 140 Views
  • 22/04/2022

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/


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK