Unique Binary Search Trees | Count all structurally unique BSTs | Catalan number | Leetcode #96

  Рет қаралды 52,375

Techdose

Techdose

Күн бұрын

Пікірлер
@prestoX
@prestoX 2 жыл бұрын
Most intuitive, thanks a ton buddy, I was reading Leetcode blogs for 3 days with all crappy methods, yours is simply brilliant and clear !
@bhuwansingh2534
@bhuwansingh2534 3 жыл бұрын
The only time JEE level maths was used again.
@anitasrivastava983
@anitasrivastava983 4 жыл бұрын
The man , the myth , the legend uploads once again!
@techdose4u
@techdose4u 4 жыл бұрын
😅
@regularsizedpanda
@regularsizedpanda 4 жыл бұрын
Coldzera!!!!
@shresthmishra9329
@shresthmishra9329 4 жыл бұрын
This explanation helped me to solve another famous problem ''intersecting chords in a cirlce". Thank you tech dose.
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@vipulsharma7190
@vipulsharma7190 4 жыл бұрын
how did you solve that by using this?
@shresthmishra9329
@shresthmishra9329 4 жыл бұрын
@@vipulsharma7190 Because it can be solved using catalan number method. Suppose you a have a circle wihtout any cuts then it is complete 1 unit. But when you make 1 cut then circle is distributed in two parts. (1+1=2). Then when you make the second cut total number of parts of the circle will be 2 parts pahle se the + 2 (because this is the second cut) . Now in total you have 4 cuts. And now if you cut the third cut then 4 pahle se + 3(because this is the third cut). So total parts of circle is 7. Again if make the 4th cut then 7 + 4 (4 becauae this is the 4th cut) So total parts of circle = 11. And this is how it goes on which can be solved with the help of catalan number method.
@vipulsharma7190
@vipulsharma7190 4 жыл бұрын
@@shresthmishra9329 thanks bro for explanation
@shresthmishra9329
@shresthmishra9329 4 жыл бұрын
@@vipulsharma7190 ☺️
@sujithns5033
@sujithns5033 4 жыл бұрын
This channel is very underrated. Nice explanation!
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@ravipatiramya4185
@ravipatiramya4185 3 жыл бұрын
@@techdose4u can u share the link where u exaplained Catalan number
@bhavitmathur5476
@bhavitmathur5476 3 жыл бұрын
Very Helpful Videos. Please keep posting
@rimpiranibaruah5353
@rimpiranibaruah5353 3 жыл бұрын
Great explanation
@techdose4u
@techdose4u 3 жыл бұрын
Thanks :)
@Official-tk3nc
@Official-tk3nc 4 жыл бұрын
Great video . I think you are an Indian because no one in youtube could teach better than Indian ...... atleast cse concepts :) ###nitjstudenthere
@nagalakshmi1385
@nagalakshmi1385 4 жыл бұрын
very good video, first time subscriber, want to check out your other videos too. your implementation is Order of n square. Order of n implementation is " long Cn=1; for(int n=0;n
@BarkaDog
@BarkaDog 4 жыл бұрын
In interviews, you can be expected to explain more than one approach. So you should always be prepared.
@techdose4u
@techdose4u 4 жыл бұрын
Yes true
@kunalsoni7681
@kunalsoni7681 4 жыл бұрын
Such a great video explanation ☺️😊.. thank you sir
@techdose4u
@techdose4u 4 жыл бұрын
Welcome
@okeyD90232
@okeyD90232 2 жыл бұрын
You should add this to your tree playlist.
@techdose4u
@techdose4u 2 жыл бұрын
Sure
@Utkarshkharb
@Utkarshkharb 3 жыл бұрын
Very well explained. Subbed!
@techdose4u
@techdose4u 3 жыл бұрын
Thanks 😊
@paragroy5359
@paragroy5359 4 жыл бұрын
Nice explanation sir...
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@kuangyimeng8850
@kuangyimeng8850 2 жыл бұрын
very clear explanation. Thank you.
@siddhartha.saif25
@siddhartha.saif25 4 жыл бұрын
very helpful. thanks
@techdose4u
@techdose4u 4 жыл бұрын
Welcome
@chetanpatteparapu7600
@chetanpatteparapu7600 4 жыл бұрын
This is very helpful bro ... Thanks a lot..
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@melwinalm
@melwinalm 4 жыл бұрын
As always, great explanation
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@deepakjoshi4374
@deepakjoshi4374 11 ай бұрын
5:21, one small correction, the correct formula will be Cn=∑i=0,n−1 (CiCn−i−1. ) It will go to n-1, not upto n.
@biranchinarayanpadhi9067
@biranchinarayanpadhi9067 4 жыл бұрын
Brillaint 3xplanation bro!!!
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@devanshgoel3433
@devanshgoel3433 2 жыл бұрын
thank u sir!
@aadityakiran_s
@aadityakiran_s Жыл бұрын
Hey, your channel is great and your explanations are very nice. I also noticed that your handwriting is very legible. What's the setup you use for whiteboarding? Do you do it using a digital drawing pad?
@kunalsoni7681
@kunalsoni7681 4 жыл бұрын
Helpful video 😊 too much for interview Thank you always
@techdose4u
@techdose4u 4 жыл бұрын
Welcome
@SiddheshKukade
@SiddheshKukade Жыл бұрын
thanks
@abhijeetkumar2204
@abhijeetkumar2204 4 жыл бұрын
class Solution { long long dp[100000]={0}; int catalan(int n) { if(n==0) { return 1; } if(dp[n]!=0) { return dp[n]; } int ans=0; for(int i=1;i
@techdose4u
@techdose4u 4 жыл бұрын
👍
@yitingg7942
@yitingg7942 3 жыл бұрын
Thank you by watching this video alone I know how to solve it. What about 95. Unique Binary Search Trees II ? I think it's much harder than this.
@techdose4u
@techdose4u 3 жыл бұрын
Yea it must be!! Since you told me 😅 lol
@aayush5474
@aayush5474 4 жыл бұрын
Itna mazaa kyu aa rha haiii😀
@techdose4u
@techdose4u 4 жыл бұрын
😂
@SuhasSrivats
@SuhasSrivats 4 жыл бұрын
In short, this is the formula: Catalan Number = (2n)!/((n+1)!*n!)
@techdose4u
@techdose4u 4 жыл бұрын
Right
@thoufeequeshaque3937
@thoufeequeshaque3937 8 ай бұрын
first example binary search tree (BST) structure is invalid . All nodes in the right subtree of a node must have values greater than the node's value. All nodes in the left subtree of a node must have values lesser than the node's value.
@rajaganji7982
@rajaganji7982 2 жыл бұрын
when n=4; C0=0; C1=1; C2=2; C3=3; = C0*C1 + C1*C2 + C2*C1 + C3*C = 0*3 + 1*2 + 2*1 + 3*0 = 4. But 4 is wrong. Please let me know if I am wrong.
@AmanSharma-or5vh
@AmanSharma-or5vh 2 жыл бұрын
best
@orugantilokesh1579
@orugantilokesh1579 4 жыл бұрын
I am viewing the solution directly , i couldn't think of any method to solve it , is it alright or should i change my approch.
@BarkaDog
@BarkaDog 4 жыл бұрын
If you made no progress in 30 minutes then look at the solution.
@techdose4u
@techdose4u 4 жыл бұрын
It's alright. You don't have to know everything. Just keep learning new concepts.
@pwnweb5734
@pwnweb5734 2 жыл бұрын
AND.. how are we supposed to come up with this formula during interview ? NOP , not intuitive
@meghamalviya8495
@meghamalviya8495 4 жыл бұрын
Can you please clear my doubt as to why and how we would have only 3 combinations of 2,3,4 (i.e. c3) in the right subtree when taking 1 as a root? Why won't there be 5 structurally unique combinations at there (for 2,3,4) because we would get 5 as a answer when we have n=3?
@techdose4u
@techdose4u 4 жыл бұрын
Actually C3 means count of no of unique BSTs with 3 unique numbers. It is not an exact value. Think of it as an unknown constant.
@meghamalviya8495
@meghamalviya8495 4 жыл бұрын
@@techdose4u ohk..thanks!
@ayushganguli1359
@ayushganguli1359 4 жыл бұрын
Hi, could you please upload a video to generate unique binary search tree in the range [1,n] please
@techdose4u
@techdose4u 4 жыл бұрын
Sure. That is an extended question.
@lokeshojha1542
@lokeshojha1542 4 жыл бұрын
int count_BT(int n){ if(n
@alirezaamedeo
@alirezaamedeo 3 жыл бұрын
5:22 You wrote Catalan number wrong. It should be C(n+1) = Sigma...
@kevinchittilapilly8221
@kevinchittilapilly8221 3 жыл бұрын
Can anyone explain why T[0] is taken as 1? If there are no nodes then shouldn't total bst be 0?
@calvin2042
@calvin2042 3 жыл бұрын
No structure is a unique structure.
@ashutosh61290
@ashutosh61290 Жыл бұрын
jab sb kuch dusre video se hi dekhna tha toh ye video kyu bnaye ??
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,6 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 31 МЛН
Lecture 127: Unique Binary Search Trees || Catalan Number
20:27
CodeHelp - by Babbar
Рет қаралды 46 М.
Remove K digits | Build lowest number | Leetcode #402
15:30
Techdose
Рет қаралды 89 М.
979. Distribute Coins in Binary Tree | Tricky DFS | Recursion
17:24
Aryan Mittal
Рет қаралды 4,7 М.
Count Complete Tree Nodes | Leetcode #222
13:39
Techdose
Рет қаралды 35 М.
3 Types of Algorithms Every Programmer Needs to Know
13:12
ForrestKnight
Рет қаралды 501 М.
Unique Binary Search Trees 1 || #DynamicProgramming
22:56
Code with Alisha
Рет қаралды 8 М.