Best Time to Buy and Sell Stock III | Leetcode #123



This video explains a very important programming interview problem which is buy and sell stock 3 which is from leetcode 123.I have already explained buy and sell stock 2 and buy and sell stock with cooldown and the LINK for these are present below.In this problem, i have explained the solution along with intuition for solving the problem.I have first shown the solution using backtracking and recursion and then i have shown the optimization using multi state memoization array.I have also shown an alternate memoization technique which is by using key as string (containing all appended states) and value as maximum profit obtained for that state.I have also shown all possible state transitions for all possible choices.The second method is by using divide and conquer technique which is intuitive if we divide the entire stock days into 2 parts and we take the maximum profit from each part and just add them to get max profit.I have shown intuition with examples for solving using divide and conquer.At the end of the video,I have explained the code walk through for both the techniques.CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful…CYA 🙂

========================================================================
Join this channel to get access to perks:
https://www.youtube.com/channel/UCnxhETjJtTPs37hOZ7vQ88g/join

INSTAGRAM : https://www.instagram.com/surya.pratap.k/

SUPPORT OUR WORK: https://www.patreon.com/techdose

LinkedIn: https://www.linkedin.com/in/surya-pratap-kahar-47bb01168

WEBSITE: https://techdose.co.in/

TELEGRAM Channel LINK: https://t.me/codewithTECHDOSE

TELEGRAM Group LINK: https://t.me/joinchat/SRVOIxWR4sRIVv5eEGI4aQ
=======================================================================

CODE LINK: https://gist.github.com/SuryaPratapK/0ae68f837c87c8504d4c682c521899c6
USEFUL VIDEOS:-
Best time to buy and sell stock 2: https://youtu.be/K8iHi8AW1ls
Best time to buy and sell stock with cooldown: https://youtu.be/4wNXkhAky3s

Leave a Comment

Your email address will not be published. Required fields are marked *


Recent Posts

TikTok
rifat_newaz

เพลงในแอพtiktok เพลงใหม่ล่าสุด 2021 รวมเพลงในtiktok [เพลงติ๊กต๊อก🔥] วัยรุ่นชอบโดนใจ ฮิตติดชาร์ต

รวมเพลงฮิตติดชาร์ตประจําสัปดาห์ เพลงในแอพTikTok รวมเพลงในtiktok รวมเพลงเพราะๆ เพลงใหม่ล่าสุด 2021 [เพลงติ๊กต๊อก2021 เพลงฮิตในtiktok] มกราคม 2564

Read More »