Check Completeness of a Binary Tree - Leetcode 958 - Python

  Рет қаралды 13,347

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 23
@rithickchowdhury7116
@rithickchowdhury7116 Жыл бұрын
Key is once you find a null node , you mustn't get any other non null node from the tree..if there is the return false.
@Vancha112
@Vancha112 Жыл бұрын
Very clear:) even for someone with very little dsa experience, thanks!
@tuandino6990
@tuandino6990 4 ай бұрын
Beautiful solution, I write 1 page long of code for this problem ...
@shubhamsharma6033
@shubhamsharma6033 Жыл бұрын
You make it very easy to understand. So, when I am stuck on a problem. I go to your channel
@victoriatfarrell
@victoriatfarrell Жыл бұрын
My solution was similar in principle but a lot longer. Thanks for sharing this, very succinct!
@sergiohernandez72
@sergiohernandez72 Жыл бұрын
Still making great videos, keep up the great work. I like that I can pretty much solve it just from your explanation before you even show the code.
@akhma102
@akhma102 Жыл бұрын
very needed. thank you!
@krateskim4169
@krateskim4169 Жыл бұрын
This is such a great solution
@ambarkansal
@ambarkansal Жыл бұрын
dhanyavad ji 🟠⚪🟢
@mohithadiyal6083
@mohithadiyal6083 Жыл бұрын
Amazing explanation 👍
@saurabhd7990
@saurabhd7990 Жыл бұрын
Thanks for the video
@Tim_desu
@Tim_desu Жыл бұрын
so brilliant... I just came out with some bad methods and messy code
@x12624
@x12624 Жыл бұрын
What does he use for drawing? How do you draw in the same page as the question? Do you use an iPad to draw and write?
@DinujayaRajakaruna
@DinujayaRajakaruna Жыл бұрын
I think he uses paint, he must have taken a screen grab of the problem and paste it on the canvas
@hufsonian
@hufsonian Жыл бұрын
that was beautiful
@hoyinli7462
@hoyinli7462 Жыл бұрын
super smarrt!
@akshitaven9060
@akshitaven9060 Жыл бұрын
Could someone help me understand why the space complexity not O(log n) which is the height of the three?
@mubeenkodvavi6308
@mubeenkodvavi6308 Жыл бұрын
The space complexity is not O(log n) as BFS traverses the tree level by level, and not store elements by node's path like DFS At one time, max queue size (space needed) will be the max width of the tree, that is O(n/2 + 1) indicating last level of complete binary tree, which is simplified to O(n)
@dark_sky3177
@dark_sky3177 Жыл бұрын
Amazing explanation..._/\_
@shubhamraj25
@shubhamraj25 Жыл бұрын
C++ implementation bool isCompleteTree(TreeNode* root) { bool flag = false; queue q; q.push(root); while (!q.empty()) { int n = q.size(); for (int i = 0; i < n; i++) { TreeNode* node = q.front(); q.pop(); if (!node) { flag = true; } else { if (flag) { return false; } q.push(node->left); q.push(node->right); } } } return true; }
@mubeenkodvavi6308
@mubeenkodvavi6308 Жыл бұрын
You dont need inner for loop for this use case.
@kevinjmathews2964
@kevinjmathews2964 Жыл бұрын
@@mubeenkodvavi6308 yeah not required. But for some reason leetcode gives a better runtime with the for loop (at least for python that's the case).
@committedeel1751
@committedeel1751 Жыл бұрын
@@kevinjmathews2964 leetcode runtime is biased so I wouldn't be too reliant on it - as long as you can explain your solution in great detail with runtime you should be fine
Construct String from Binary Tree - Leetcode 606 - Python
10:00
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 149 МЛН
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 13 МЛН
LOWEST COMMON ANCESTOR OF A BINARY TREE II | PYTHON | LEETCODE 1644
20:46
Why is Python 150X slower than C?
10:45
Mehul - Codedamn
Рет қаралды 18 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 151 М.
Binary tree: Level Order Traversal
11:23
mycodeschool
Рет қаралды 612 М.
Insert into a Binary Search Tree - Leetcode 701 - Python
9:48
NeetCodeIO
Рет қаралды 15 М.
⚡️NEWS | RUBLE COLLAPSE | STRIKE ON CRIMEA | PUTIN IN KAZAKHSTAN
10:34
Ходорковский LIVE
Рет қаралды 190 М.
Binary Search Tree Iterator - Leetcode 173 - Python
12:47
NeetCode
Рет қаралды 43 М.
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 149 МЛН