Best Time To Buy & Sell Stock 1 (LeetCode 121) | Full solution with visuals and animation
HTML-код
- Опубликовано: 10 июл 2024
- Stock Market is a wonderful opportunity to make some money but surely, you need to time things correctly. In the given problem we have defined prices and our aim is to maximize the profit. Watch the video to understand with animations and visuals how we can achieve a maximum profit in just one iteration.
Actual problem on LeetCode: leetcode.com/problems/best-ti...
Chapters:
00:00 - Intro
00:56 - Problem Statement and Description
03:24 - Brute Force Solution is not optimal
05:47 - Working step by step
11:38 - Dry-run of Code
13:31 - Final Thoughts
📚 Links to topics I talk about in the video:
LeetCode Problems: • Leetcode Solutions
Other easy difficulty problems: • Easy Problems
Dynamic Programming: • Dynamic Programming ea...
Greedy Algorithms: • Greedy Algorithms with...
Kadane’s Algorithm: • Maximum Sub-Array Sum ...
📘 A text based explanation is available at: studyalgorithms.com
Code on Github: github.com/nikoo28/java-solut...
Test-cases on Github: github.com/nikoo28/java-solut...
📖 Reference Books:
Starting Learn to Code: amzn.to/36pU0JO
Favorite book to understand algorithms: amzn.to/39w3YLS
Favorite book for data structures: amzn.to/3oAVBTk
Get started for interview preparation: amzn.to/39ysbkJ
🔗 To see more videos like this, you can show your support on: www.buymeacoffee.com/studyalg...
🎥 My Recording Gear:
Recording Light: amzn.to/3pAqh8O
Microphone: amzn.to/2MCX7qU
Recording Camera: amzn.to/3alg9Ky
Tablet to sketch and draw: amzn.to/3pM6Bi4
Surface Pen: amzn.to/3pv6tTs
Laptop to edit videos: amzn.to/2LYpMqn
💻 Get Social 💻
Follow on Facebook at: / studyalgos
Follow on Twitter at: / studyalgorithms
Follow on Tumblr at: / studyalgos
Subscribe to RSS feeds: studyalgorithms.com/feed/
Join fan mail: eepurl.com/g9Dadv
#leetcode #programming #interview
Why are his lectures not having enough views? They are so good.
Thumbnail
They love only clickbait and trends. He is treasure, hope he start DSA course, I will buy at any cost.
one of the best yet simple solution i have seen so far.
Your clear explanation is so good. Clearly this video deserves more views, bless you!
thanks for your appreciation and motivation :)
How come your views are so low....its literally the best explanation i am getting on youtube ....already watched few of your videos...always thinking why you are so underrated.
So happen I randomly found you. Thank you for the content. You are definitely helping me understand the coding mindset.
bhaiya whenever i got stuck in DSA you always saved me. i have watched number of videos of yours on DSA and always got the best solution always
It's my pleasure
This explanation deserves more views and sharing with friends and colleagues. Simply brilliant
Mind Blowing Explaination , Very Clear and Consice
Thank you so much, this explanation was super helpful.
Thank you so much sir, this explanation was super helpful.
such a clean explanation with visuals, thank you!
so happy you like them
Very clear explaination
Thank you so much
Really Good content... Best video lecture on RUclips. Keep doing good work
You are a gem!
really appreciate your effort to explain and how to reach to solution step by steps. It is great help. keep it up!! thanks lot
you are very welcome!!
Brother your explanation is love
Best explanation..thanks!
better than more phd holder, great explanation
Thank you for your great explanation..it will be great if you solve hackerank array manipulation problem
You explained so well😊
Thanks man. Good coding.
great video and very well explained 😃
great explanation....thank you sir
best explanation that i found
thank you very much sir nicely explained
Thanks, it was really helpfull...
Thanks for the video
the best explanation❤❤❤❤
Thankyou sir.
great understanding
Great explanation ❤
You should be a tutor or teacher,
thanks for uploading :D
great explanation👍
well explained
Bhaiya tussi GREAT ho!!!🎉
you are great too :D
It's more better explanation than neetcode) thx
very underrated channel
Thanks
Welcome
i love your english
❤
Pls do cover all the parts of buy and sell problem if possible
yep...I do have that on my mind 😄
👍
How to find and return the indices of best day to buy and best day to sell with max profit?
that is another problem...and will cover it at a later point in time
I wrote the code myself and I am confused with the test cases...[3,2,6,5,0,3] expects the output to be 4 whereas [2,1,2,1,0,1,2] expects output to be 2. So in first testcase, the 0 price is not valid whereas in the 2nd, 0 buy price is valid ??
try debugging and you will be able to follow along the step you are missing
U are looking like that guy who host the show "the mad" in pogo❤
haha...you mean rob?
what is the name of this algorithm?
Kadane's algorithm
Sir please write code also at the last by yourself
I want to focus on the problem solving part rather than the code part. Once the algorithm is clear to you...writing the code in any language isn't hard at all. Every good company you interview for...they will only be interested to judge if you are able to think logically.
Plus, I also provide a production level code at the end with a dry run, full code and test cases on Github as well.
So my question to you is, did you face any problems while understanding how to solve?
@@nikoo28 No bhaiyaa the thing is I just started coding I understand the logic very well with your explanation but I'm not able to write in a limited time and bhaiya you explain so well that I understand the logic easily.
If you have just started your coding journey…all the more reason to try and write the code yourself…follow the logic and debug along the way.
Pause and take your time. No rush to just complete the number of problems.
@@nikoo28 okk bhaiya i will give my best
nice explanation ...keep it bro🤩
Thank you, I will
Thank you so much sir, this explanation was super helpful.