Best Time to Buy and Sell Stock iii | LeetCode 123 | C++, Java, Python

  Рет қаралды 9,712

Knowledge Center

Knowledge Center

Күн бұрын

**** CORRECTION: At 9:41 for Pmax value. It should be 4 and not 3.
LeetCode Solutions: • LeetCode Solutions | L...
August LeetCoding Challenge: • Playlist
Github Link: github.com/Kno...
*** Best Books For Data Structures & Algorithms for Interviews:*********
1. Cracking the Coding Interview: amzn.to/2WeO3eO
2. Cracking the Coding Interview Paperback: amzn.to/3aSSe3Q
3. Coding Interview Questions - Narasimha Karumanchi: amzn.to/3cYqjkV
4. Data Structures and Algorithms Made Easy - N. Karumanchi: amzn.to/2U8FrDt
5. Data Structures & Algorithms made Easy in Java - N. Karumanchi: amzn.to/2U0qZgY
6. Introduction to Algorithms - CLR - Cormen, Leiserson, Rivest: amzn.to/2Wdp8rZ
*****************************************************************************
August LeetCoding Challenge | Problem 16 | Best Time to Buy and Sell Stock iii | 16 August,
Facebook Coding Interview question,
google coding interview question,
leetcode,
Best Time to Buy and Sell Stock iii,
Best Time to Buy and Sell Stock iii c++,
Best Time to Buy and Sell Stock iii Java,
Best Time to Buy and Sell Stock iii python,
Best Time to Buy and Sell Stock iii solution,
123. Best Time to Buy and Sell Stock iii,
#CodingInterview #LeetCode #AugustCodingChallenge #Google #Amazon #StockBuySell #dynamicprogramming

Пікірлер
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
***CORRECTION:: At 9:41 for Pmax value. It should be 4 and not 3. Thanks @Isha for pointing it out.
@codestorywithMIK
@codestorywithMIK 3 жыл бұрын
For the profit2 calculation, instead of starting from beginning , we started from (n-1) i.e. in backward direction. The reason we did that because we will get the profit2 in descending order and when we will be calculating profit1[i] + profit2 [i] , we are sure to get maximum value of profit2 array. Hope this helps.
@nirmalkumarselvaraj3996
@nirmalkumarselvaraj3996 4 жыл бұрын
Thank you, please put dp version of solving for the same problem
@crankyinmv
@crankyinmv 4 жыл бұрын
Elegant. Thanks for the video. My solution was also O(n) but not as elegant.
@isha2567
@isha2567 4 жыл бұрын
I think there is mistake at 9:41 for Pmax value. It should be 4 and not 3 as it is not updated. kzbin.info/www/bejne/Zneun2N8iK6Ej6c
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks for pointing it out. Have added it now to the description, and Comment.
@harshvardhanr5062
@harshvardhanr5062 4 жыл бұрын
can u make a video on the solution for atmost k transactions
@MYUCOZ1
@MYUCOZ1 3 жыл бұрын
why we go in opposite direction for the second half?
@prateekagrawal8166
@prateekagrawal8166 4 жыл бұрын
why did we put j=n-i-1? What is the logic behind that? I'm not getting it. I mean yes we want to sell atmost "two" times,but why assigning j as n-i-1?
@parthpandya7833
@parthpandya7833 2 жыл бұрын
Because we have to update the array from second last elememt At Last element profit will be zero
@jaegukim3599
@jaegukim3599 4 жыл бұрын
Thank You!
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Welcome!
Non-overlapping Intervals | LeetCode 435 | C++, Java, Python
20:35
Knowledge Center
Рет қаралды 7 М.
🕊️Valera🕊️
00:34
DO$HIK
Рет қаралды 5 МЛН
Design HashSet | LeetCode 705 | C++, Java, Python
28:27
Knowledge Center
Рет қаралды 19 М.
Best Time to Buy and Sell Stock III | Leetcode #123
35:40
Techdose
Рет қаралды 70 М.
Power of Four | LeetCode 342 | C++, Java, Python
12:11
Knowledge Center
Рет қаралды 11 М.
Vertical Order Traversal of a Binary Tree | LeetCode 987 | C++, Python
25:52
DP 36. Buy and Sell Stock - II | Recursion to Space Optimisation
35:34
take U forward
Рет қаралды 238 М.
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 179 М.