Master Data Structures & Algorithms for FREE at AlgoMap.io/
@paranoiak6696 күн бұрын
My solution was this code : profit = 0 for i in range(len(prices)-1): diff = prices[i+1]-prices[i] if diff>0: profit += diff return profit No need to calculate low and high here. But as always, great video !
@thomasbooth27783 ай бұрын
Theres also a really nice greedy solution to this also. Where it mentions 'You can buy it then immediately sell it on the same day.' Was something I overlooked at the start and wrote a solution like yours. Definitely worth noting to look for small bits of info like this in problems
@JoeTan-nq4fq2 ай бұрын
Love your videos. Concise and easy to understand.
@RuoyanJiang2 ай бұрын
Love your video, it was concise, the solution was easy to understand and definitely helped me prepare for the interview, thanks :)
@JoeTan-nq4fq2 ай бұрын
It would be similar that we calculate the difference of today's and y'day's price for all prices. The max profit would be the sum of all the profits (ignore the losses).
@angelomarano84583 ай бұрын
love this videos, very helpfull!.
@GregHogg3 ай бұрын
Thank you!
@ambersautner3 ай бұрын
extremely thorough and easy to understand! thank you for making these videos, im planning on binging your channel lolol
@GregHogg3 ай бұрын
Binge it up at algomap.io :)
@pawelrolbiecki7813Ай бұрын
But you can buy and sell it the same day. So why don't we do it "scalping" way? make profit "day by day" ? It simplifies the aproach and it is fatser.