Sum Root to Leaf Numbers - Coding Interview Question - Leetcode 129

  Рет қаралды 31,136

NeetCode

NeetCode

Күн бұрын

Пікірлер: 18
@NeetCode
@NeetCode 4 жыл бұрын
kzbin.info/www/bejne/hZ-2n2WOerZng7s
@chiranjeevipippalla
@chiranjeevipippalla 2 жыл бұрын
If you are a regular follower, you will love those key clicks sound from the keyboard. Could you please tell me what keyboard you are using? Thanks
@tusharrajput983
@tusharrajput983 8 ай бұрын
Other option is to fetch a vector of string from the left and right recursive calls, that contains all the numbers as a string. Just concatenate your root to those strings and return. Calc sum by traversing over the final vector.
@nikhilgoyal007
@nikhilgoyal007 Жыл бұрын
I thought it should add to a total result variable when node.left and node.right are absent rather than return straight up ?
@veliea5160
@veliea5160 2 жыл бұрын
You said it is preorder becasue processing the root node first. Is not it called `inorder`?
@jelly6288
@jelly6288 2 жыл бұрын
[ pre / in / post ]order talks about when we process our current node relative to the children nodes. so pre (before) means you process the current node before your process the children, in (think inbetween) means you process the current node in between processing your children nodes, and post (after) means you process the current node after processing the children
@kitkarson4226
@kitkarson4226 3 жыл бұрын
Thanks man.. I was banging my head :(
@b9944236
@b9944236 Жыл бұрын
I like the example in the last part.
@CongNguyen-og3iz
@CongNguyen-og3iz 2 жыл бұрын
Thank you so much
@DiaaHaresYusf
@DiaaHaresYusf Жыл бұрын
your voice is so calm in this video =D
@aumrudhlalkumartj1948
@aumrudhlalkumartj1948 2 жыл бұрын
Thanks
@hhcdghjjgsdrt235
@hhcdghjjgsdrt235 2 жыл бұрын
i did this by recursion int SumNumbers(TreeNode root) { int temp = 0; int res = 0; void Recursion(TreeNode N) { temp = temp * 10 + N.val; if (N.left == null && N.right == null) { res += temp; } else { if (N.left != null) Recursion(N.left); if (N.right != null) Recursion(N.right); } temp /= 10; } Recursion(root); return res; }
@KunalTiwariBCI
@KunalTiwariBCI Жыл бұрын
he also used recursion only
@ahmadafghan6767
@ahmadafghan6767 8 ай бұрын
i was asked to Morris Preorder Traversal after given this as an answer.
@ЕрасылОразбек-ч3ъ
@ЕрасылОразбек-ч3ъ 6 ай бұрын
In meta?
@spemovie
@spemovie 2 жыл бұрын
The is a better constant memory solution
@shatakshivishnoi916
@shatakshivishnoi916 Жыл бұрын
Thankyouuuu
@mwnkt
@mwnkt 9 ай бұрын
i loved how you went through the code at the end of the video. kzbin.info/www/bejne/gJyUZ5-QfKuKrqc i miss this, wish you did it in the recent videos
RANDOM PICK INDEX | LEETCODE # 398 | PYTHON RESERVOIR SAMPLING
14:56
Don't look down on anyone#devil  #lilith  #funny  #shorts
00:12
Devil Lilith
Рет қаралды 48 МЛН
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,6 МЛН
Sum of Root To Leaf Binary Numbers | LeetCode 1022 | C++, Java, Python
15:00
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 125 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 270 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 150 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 622 М.
Continuous Subarray Sum - Leetcode 523 - Python
14:56
NeetCode
Рет қаралды 69 М.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 421 М.
Don't look down on anyone#devil  #lilith  #funny  #shorts
00:12
Devil Lilith
Рет қаралды 48 МЛН