Check Completeness of a Binary Tree - Leetcode 958 - Python

  Рет қаралды 12,544

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!
@shubhamsharma6033
@shubhamsharma6033 Жыл бұрын
You make it very easy to understand. So, when I am stuck on a problem. I go to your channel
@tuandino6990
@tuandino6990 3 ай бұрын
Beautiful solution, I write 1 page long of code for this problem ...
@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.
@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
@krateskim4169
@krateskim4169 Жыл бұрын
This is such a great solution
@akhma102
@akhma102 Жыл бұрын
very needed. thank you!
@Tim_desu
@Tim_desu Жыл бұрын
so brilliant... I just came out with some bad methods and messy code
@mohithadiyal6083
@mohithadiyal6083 Жыл бұрын
Amazing explanation 👍
@saurabhd7990
@saurabhd7990 Жыл бұрын
Thanks for the video
@ambarkansal
@ambarkansal Жыл бұрын
dhanyavad ji 🟠⚪🟢
@hufsonian
@hufsonian Жыл бұрын
that was beautiful
@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)
@hoyinli7462
@hoyinli7462 Жыл бұрын
super smarrt!
@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
Distribute Coins in Binary Tree - Leetcode 979 - Python
17:41
NeetCodeIO
Рет қаралды 16 М.
小蚂蚁会选到什么呢!#火影忍者 #佐助 #家庭
00:47
火影忍者一家
Рет қаралды 108 МЛН
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,4 МЛН
Кәсіпқой бокс | Жәнібек Әлімханұлы - Андрей Михайлович
48:57
LOWEST COMMON ANCESTOR OF A BINARY TREE II | PYTHON | LEETCODE 1644
20:46
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 458 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 109 М.
Viral Video of a Man's Crazy Job Interview
16:02
Darryl Vega TV
Рет қаралды 1,3 МЛН
Construct String from Binary Tree - Leetcode 606 - Python
10:00
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 175 М.
Binary tree: Level Order Traversal
11:23
mycodeschool
Рет қаралды 608 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 395 М.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 414 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 661 М.
小蚂蚁会选到什么呢!#火影忍者 #佐助 #家庭
00:47
火影忍者一家
Рет қаралды 108 МЛН