

Stock buy and sell | SDE Sheet | Arrays
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.

- 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
-
9
Leaders in an ArrayLeaders in an Array | SDE Sheet | ArraysVideo Player is loading.Loaded: 0%Remaining Time -0:0070 Views
-
5
Equilibrium pointEquilibrium point | SDE Sheet | ArraysVideo Player is loading.Loaded: 0%Remaining Time -0:00360 Views
-
6
Reverse array in groupsReverse array in groups | SDE Sheet | ArraysVideo Player is loading.Loaded: 0%Remaining Time -0:00120...
-
6
Missing number in arrayMissing number in array | SDE Sheet | ArraysVideo Player is loading.Loaded: 0%Remaining Time -0:0012/...
-
8
Kadane’s AlgorithmKadane’s Algorithm | SDE Sheet | ArraysVideo Player is loading.Loaded: 0%Remaining Time -0:00460 Views
-
12
Subarray with given sumSubarray with given sum | SDE Sheet | ArraysVideo Player is loading.Loaded: 0%Remaining Time -9:28280...
-
9
Trapping Rain WaterTrapping Rain Water | SDE Sheet | ArraysVideo Player is loading.Loaded: 0.48%00:00Remaining Time -10:19
-
8
Minimum PlatformsMinimum Platforms | SDE Sheet |ArraysHi. In this video, we will learn howLoaded: 0.68%00:01Remaining Ti...
-
6
Largest subarray with 0 sumLargest subarray with 0 sum | SDE Sheet | ArraysVideo Player is loading.Loaded: 0%00:00Remaining Time -10:53...
-
8
Stock span problemJanuary 06, 2024 |70 ViewsSDE Sheet - Stock span problemSDE Sheet, GFG SDE Sheet, stack Save Share LikeDescriptionDiscussion
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK