Construct Binary Tree from Preorder and Postorder Traversal | Leetcode 889

preview_player
Показать описание
This video explains Construct Binary Tree from Preorder and Postorder Traversal using the optimal recursion approach.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
🟣 JOIN our 𝐋𝐈𝐕𝐄 𝐢𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐭𝐫𝐚𝐢𝐧𝐢𝐧𝐠 𝐩𝐫𝐨𝐠𝐫𝐚𝐦 through whatsapp query: +91 8918633037
---------------------------------------------------------------------------------------------------------------------------------------------------------------

Рекомендации по теме
Комментарии
Автор

Sir, why you already write the code? You should write code line by line and again explain it in a linear way...But your explanation logic is good 👍.

worldcurrenttimes
Автор

Hi bro, There is another solution which doesn't have any side effects. Interviewer might expect something without side effects 'cause using a global variable will be a pain during debugging. That solution is easy too, instead of update index varaible we just pass index+1 to the left subtree call and it will return the index that needs to be processed and we'll pass the returned index to the right subtree. This was the solution I first learned, but the other version not only gives the correct answer but also improves our recursive thinking IMO.

Sirpi-ir
Автор

used a combination of set and stack making my space complexity little inefficient

Anikait-hd
Автор

More difficult than yesterday's one

maheshgnayak
Автор

Sir SC must be O(2N) no? N for tree and N for recursion stack?

shreyanmajumdar
Автор

But jo apne 3 wala steo btaya like 3 hoga to aage badho wo to aapne code mai include he nahi kiya sir ji

btkitsprings
Автор

😉❤. This was seriously a hard problem, more difficult than yesterday's. Since I have already solved the other 2 similar problem, it was easy to come up with intuition but coding it is really hard.
My Approach is different still good to know your solution.

freecourseplatformenglish