Top Algorithm Interview Questions Fully Explained: Best time to Buy and Sell Stock
Jadi
We have a list of a stock price on each day and we can buy on a specific day and sell on a day in the future, target is clear: maximize the profit!
I will start by showing you a "bad" solution and analyzing why its bad! This leads us to a practical introduction to the BIG O notation. Then we will look for a better solution which satisfies our interviewer.
00:00 - Buy and sell stock algorithm 02:19 - Ugly O(n^2) solution with nested fors 03:24 - Why O(n^2) is bad; a javascript sample 09:00 - A good solution for stock buy and sell question
Question on leetcode: https://leetcode.com/problems/best-time-to-buy-and-sell-stock ... https://www.youtube.com/watch?v=qtuOSS1pA3c
2024-09-07
0.0 LBC
Copyrighted (contact publisher)
67182234 Bytes