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

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

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 15
@youtubeuserlovesyoutube2207
@youtubeuserlovesyoutube2207 5 ай бұрын
thanks aryan GOAT
@mohammedansil2302
@mohammedansil2302 5 ай бұрын
Thanks clear explanation
@codebreaker6578
@codebreaker6578 5 ай бұрын
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 5 ай бұрын
nice
@insaneclutchesyt948
@insaneclutchesyt948 5 ай бұрын
u must be a genius
@codebreaker6578
@codebreaker6578 5 ай бұрын
@@insaneclutchesyt948 but didn't optimal approach
@cenacr007
@cenacr007 5 ай бұрын
@codebreaker6578
@codebreaker6578 5 ай бұрын
I didn't do any tree question till now should i do this ?
@insaneclutchesyt948
@insaneclutchesyt948 5 ай бұрын
my dumbass thought vertical order traversal to get the sum of all the right nodes
@codebreaker6578
@codebreaker6578 5 ай бұрын
can you please explain how recursive is using O(n) space , in itertative it's because of stack
@ajayprabhu465
@ajayprabhu465 5 ай бұрын
Function stack space takes O(n)
@ITACH1688
@ITACH1688 5 ай бұрын
recursive function calls are managed using call stack.
@codebreaker6578
@codebreaker6578 5 ай бұрын
@@ajayprabhu465 👍
@codebreaker6578
@codebreaker6578 5 ай бұрын
@@ITACH1688 👍
@lokesh8660
@lokesh8660 5 ай бұрын
waiting for today's dc in place modification approach 🥲
94. Binary Tree Inorder Traversal | Morris Traversal | Space - O(1)
28:09
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 86 МЛН
AVL Trees & Rotations (Self-Balancing Binary Search Trees)
20:38
Back To Back SWE
Рет қаралды 352 М.
Evaluate Boolean Binary Tree - Leetcode 2331 - Python
14:55
NeetCodeIO
Рет қаралды 8 М.
1382. Balance a Binary Search Tree - Day 26/30 Leetcode June Challenge
16:05
Programming Live with Larry
Рет қаралды 808
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 444 М.
Leetcode 894. All Possible Full Binary Trees
29:08
Code with Alisha
Рет қаралды 4,3 М.
TCP/IP for Programmers
3:03:31
Eli the Computer Guy
Рет қаралды 229 М.
Binary Tree Algorithms for Technical Interviews - Full Course
1:48:53
freeCodeCamp.org
Рет қаралды 734 М.
Lecture 127: Unique Binary Search Trees || Catalan Number
20:27
CodeHelp - by Babbar
Рет қаралды 46 М.
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН