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
@tusharrajput9838 ай бұрын
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 Жыл бұрын
I thought it should add to a total result variable when node.left and node.right are absent rather than return straight up ?
@veliea51602 жыл бұрын
You said it is preorder becasue processing the root node first. Is not it called `inorder`?
@jelly62882 жыл бұрын
[ 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
@kitkarson42263 жыл бұрын
Thanks man.. I was banging my head :(
@b9944236 Жыл бұрын
I like the example in the last part.
@CongNguyen-og3iz2 жыл бұрын
Thank you so much
@DiaaHaresYusf Жыл бұрын
your voice is so calm in this video =D
@aumrudhlalkumartj19482 жыл бұрын
Thanks
@hhcdghjjgsdrt2352 жыл бұрын
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 Жыл бұрын
he also used recursion only
@ahmadafghan67678 ай бұрын
i was asked to Morris Preorder Traversal after given this as an answer.
@ЕрасылОразбек-ч3ъ6 ай бұрын
In meta?
@spemovie2 жыл бұрын
The is a better constant memory solution
@shatakshivishnoi916 Жыл бұрын
Thankyouuuu
@mwnkt9 ай бұрын
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