Загрузка...

Top Algorithm Interview Questions Fully Explained: Best time to Buy and Sell Stock

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

Видео Top Algorithm Interview Questions Fully Explained: Best time to Buy and Sell Stock канала Jadi
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять