Increasing Order Search Tree | Leetcode 897 | BST | Day-17

  Рет қаралды 6,390

Ayushi Sharma

Ayushi Sharma

Күн бұрын

Пікірлер: 46
@soubhikroy9978
@soubhikroy9978 2 жыл бұрын
mam thanks for regular this type of wonderful content
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Welcome Soubhik, glad you liked it :)
@nishantgarg2815
@nishantgarg2815 2 жыл бұрын
This is the most clean solution I've seen for this problem without creating new nodes. Good job.
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Thank you Nishant :)
@LifestyleSoulDevu
@LifestyleSoulDevu 2 жыл бұрын
Thanks Ayushi for the series!
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Welcome Devanjali, glad you liked it :)
@aahanaganjewar9951
@aahanaganjewar9951 2 жыл бұрын
class Solution { ArrayList inorder = new ArrayList(); public TreeNode increasingBST(TreeNode root) { TreeNode dummy = new TreeNode(); TreeNode curr = dummy; utilTravel(root); for (TreeNode node : inorder) { curr.right = node; curr = curr.right; } return dummy.right; } public void utilTravel(TreeNode root) { if (root == null) { return; } utilTravel(root.left); TreeNode temp = new TreeNode(root.val); inorder.add(temp); utilTravel(root.right); } }
@dhanrajlouvanshi7872
@dhanrajlouvanshi7872 2 жыл бұрын
Special Thanks for Providing java solutions
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Welcome Dhanraj :) Glad it is helpful :)
@soubhikroy9978
@soubhikroy9978 2 жыл бұрын
one more request mam can please discuss leetcode weekly contest question
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Hi Soubhik, yes everytime I think to make video, but then get stuck in some work. I'll surely try :)
@sakshamsengar9798
@sakshamsengar9798 2 жыл бұрын
10:22 "otherwise i will make a left kol*******....... call " . highlight of the video 😂😂
@amitsinha806
@amitsinha806 2 жыл бұрын
you are always awesome 😎😎😎😎
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Thanks :)
@rohitraj5832
@rohitraj5832 2 жыл бұрын
@Ayushi Sharma the same approach i've followed as yours, but am not getting the correct o/p.. plz have a look void inorder(TreeNode* root, TreeNode* temp){ if(root==NULL)return; inorder(root->left,temp); temp->right=root; temp=root; root->left=NULL; inorder(root->right,temp); } TreeNode* increasingBST(TreeNode* root) { TreeNode* dummy=new TreeNode(0); TreeNode* temp=dummy; inorder(root,temp); return dummy->right; }
@tejaswigutta9017
@tejaswigutta9017 2 жыл бұрын
When we backtrack, temp is not updated as it is a local variable. Dry run it once you will understand @rohit raj
@tejaswigutta9017
@tejaswigutta9017 2 жыл бұрын
class Solution { public TreeNode increasingBST(TreeNode root) { TreeNode dummy=new TreeNode(-1); convert(root,dummy); return dummy.right; } public TreeNode convert(TreeNode root,TreeNode dummy){ if(root==null) return dummy; TreeNode left=convert(root.left,dummy); left.right=root; left=root; left.left=null; return convert(root.right,left); } } This will work . Try to understand this :)
@shekharchaugule7700
@shekharchaugule7700 2 жыл бұрын
that's great
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Thank you Shekhar :)
@onlydharamsanatandharam
@onlydharamsanatandharam Жыл бұрын
thank you very much, when question are not going in mind and if that question's video found on your youtube channel than i'm free ... ki ab to ho jayega😎 thank u very much.
@AyushiSharmaDSA
@AyushiSharmaDSA 6 ай бұрын
thank you, glad it was helpful😄
@aryangoyal2252
@aryangoyal2252 2 жыл бұрын
I tried the same way but made helper function return aa treenode rather than making it void and globally declaring the curr. this made me confused what to return from helper function everytime and that's where I give up. thanks for this explanation.
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Yeah, first I also thought of doing that, but then I thought it's better to make global variable, this is how we learn :)
@aryangoyal2252
@aryangoyal2252 2 жыл бұрын
@@AyushiSharmaDSA yes mam , i will defineitly keep this in mind from next time.
@ChandraShekhar-by3cd
@ChandraShekhar-by3cd 2 жыл бұрын
Thanks for great explanation. I had one small doubt regarding the use of `current ` as member variable. Is it the right way to define it??
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Welcome Chandra, Yes, but you can make it global variable as well :)
@ChandraShekhar-by3cd
@ChandraShekhar-by3cd 2 жыл бұрын
@@AyushiSharmaDSA Ok, Thanks Ayushi.
@dipanshmalhotra
@dipanshmalhotra 2 жыл бұрын
OP explaination didi helpes a lot (writing smj nhi aai pr approach aagai...XD)
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Thank you Dipansh :) aaj pta ni mouse ko kya hogya, chal hi nhi rha sahi se😂
@amanbhadani8840
@amanbhadani8840 2 жыл бұрын
Too much Easy 🙃
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
✌🏻😊
@divine5863
@divine5863 2 жыл бұрын
Hii Didii.. can you give multiple solutions for problems on leetcode.. so that we can think in broader sense..
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Sure, thanks for valuable feedback. I'll take care from next video onwards 🙂
@markandeysharma9771
@markandeysharma9771 2 жыл бұрын
Mam should I take the course u buyed in 2year for cn???
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
The course was good, if you want to buy, you can buy. I took dsa in cpp module
@markandeysharma9771
@markandeysharma9771 2 жыл бұрын
@@AyushiSharmaDSA sure but I going through anuj bhaiya is it okay ??
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
@@markandeysharma9771 sorry i haven't seen the content, so can't say anything. :)
@markandeysharma9771
@markandeysharma9771 2 жыл бұрын
@@AyushiSharmaDSA sure
@dipanshmalhotra
@dipanshmalhotra 2 жыл бұрын
eagerly waitinng for new video didi where is new video.
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
Hi Dipansh, will upload in some time, sorry for delay :)
@dipanshmalhotra
@dipanshmalhotra 2 жыл бұрын
@@AyushiSharmaDSA koi nhi didi its ok i tried question and finally in the world i solved the trees question:)
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
@@dipanshmalhotra awsm🙌🏻🙌🏻🙌🏻🔥
@corporatebhai1703
@corporatebhai1703 2 жыл бұрын
why are we doing node->left=NULL didn't understand
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
see because in result tree, for every node, left is null.
@corporatebhai1703
@corporatebhai1703 2 жыл бұрын
@@AyushiSharmaDSA shouldn't we do current->left=null then as that is the tree we are returning
@AyushiSharmaDSA
@AyushiSharmaDSA 2 жыл бұрын
@@corporatebhai1703 we can do that also :) like this void helper(TreeNode* node) { if(node == NULL) { return; } helper(node->left); current->right = node; current = node; current->left = NULL; helper(node->right); }
Recover Binary Search Tree | Leetcode 99 | BST | Day-19
15:54
Ayushi Sharma
Рет қаралды 5 М.
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 42 МЛН
Compare Version Numbers | Leetcode 165 | Strings | Day-25
14:29
Ayushi Sharma
Рет қаралды 10 М.
L27. Lowest Common Ancestor in Binary Tree | LCA | C++ | Java
14:09
take U forward
Рет қаралды 328 М.
Container With Most Water | Leetcode 11 | Two pointers | Day-5
21:05
Kth Smallest Element in a BST | Leetcode 230 | BST | Day-18
12:17
Ayushi Sharma
Рет қаралды 5 М.
I Coded Minecraft’s Hardest Difficulty
16:36
McMakistein
Рет қаралды 114 М.
Binary Tree Cameras | Leetcode 968 | Recursion
22:26
Ayushi Sharma
Рет қаралды 5 М.
L52. Recover BST | Correct BST with two nodes swapped
15:56
take U forward
Рет қаралды 134 М.
How many people are in the changing room? #devil #lilith #funny #shorts
00:39