1038. Binary Search Tree to Greater Sum Tree | Recursive | Iterative | Morris Traversal

  Рет қаралды 2,888

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 15
@youtubeuserlovesyoutube2207
@youtubeuserlovesyoutube2207 4 ай бұрын
thanks aryan GOAT
@mohammedansil2302
@mohammedansil2302 4 ай бұрын
Thanks clear explanation
@codebreaker6578
@codebreaker6578 4 ай бұрын
I can't believe myself that i done this problem without watching this video . Because it's my first tree problem ,I just saw GFG how to traverse tree and came up with solution which passed all testcase in single run with time complexity O(N) class Solution { public: int sum=0; void update(TreeNode* node){ if(node==nullptr){ return; } update(node->right); sum+=node->val; node->val=sum; update(node->left); } TreeNode* bstToGst(TreeNode* root) { update(root); return root; } };
@abhinay.k
@abhinay.k 4 ай бұрын
nice
@insaneclutchesyt948
@insaneclutchesyt948 4 ай бұрын
u must be a genius
@codebreaker6578
@codebreaker6578 4 ай бұрын
@@insaneclutchesyt948 but didn't optimal approach
@cenacr007
@cenacr007 4 ай бұрын
@codebreaker6578
@codebreaker6578 4 ай бұрын
I didn't do any tree question till now should i do this ?
@insaneclutchesyt948
@insaneclutchesyt948 4 ай бұрын
my dumbass thought vertical order traversal to get the sum of all the right nodes
@codebreaker6578
@codebreaker6578 4 ай бұрын
can you please explain how recursive is using O(n) space , in itertative it's because of stack
@ajayprabhu465
@ajayprabhu465 4 ай бұрын
Function stack space takes O(n)
@ITACH1688
@ITACH1688 4 ай бұрын
recursive function calls are managed using call stack.
@codebreaker6578
@codebreaker6578 4 ай бұрын
@@ajayprabhu465 👍
@codebreaker6578
@codebreaker6578 4 ай бұрын
@@ITACH1688 👍
@lokesh8660
@lokesh8660 4 ай бұрын
waiting for today's dc in place modification approach 🥲
543. Diameter of Binary Tree | 3 Ways | Tree | ⭐️IMPORTANT⭐️
21:54
HELP!!!
00:46
Natan por Aí
Рет қаралды 5 МЛН
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,8 МЛН
The TRIPLE FOLDING phone has a Problem.
12:54
Mrwhosetheboss
Рет қаралды 1,8 МЛН
Microsoft Makes Windows Worse With AI
9:34
Mental Outlaw
Рет қаралды 160 М.
2751. Robot Collisions | Stack | Sorting | Not Hard 🫡
19:30
Aryan Mittal
Рет қаралды 6 М.
94. Binary Tree Inorder Traversal | Morris Traversal | Space - O(1)
28:09
Number of Dice Rolls with Target Sum - Leetcode 1155 - Python
20:20
Where Does Bad Code Come From?
42:21
Molly Rocket
Рет қаралды 197 М.
HELP!!!
00:46
Natan por Aí
Рет қаралды 5 МЛН