LeetCode 894. All Possible Full Binary Trees

preview_player
Показать описание

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

If I try to use the same solution as yours, I run into stack over flow error. The solution even before memorisation optimisation at 16:50 causes stack over flow for me.
for i=3, the recursive call starts again for 1..3 for left sub tree and then it continues never ending.

vishaljoshi
Автор

Thanks for sharing this! Couldn't quite get it from the solutions posted on LeetCode, but this was very easy to follow. Good job!

adamgy
Автор

What is the chrome extension you are using to write on leetcode page?

YashLadia
Автор

Beautiful explanation. Thank you kind sir!

harshpranami
Автор

Great explanation, but one thing to point out though. You aren't actually making deep copies. What you are making are Frankenstein trees. They have branches that are shared in more than one tree. Updatation, deletion are all going to mess up with all the other trees.

What you can do instead is to use a function where you create a new Node which will make a deep copy.

aseembaranwal
Автор

Can you please explain the time and space complexity for the memorisation approach?

sachinrai