mam thanks for regular this type of wonderful content
@AyushiSharmaDSA2 жыл бұрын
Welcome Soubhik, glad you liked it :)
@nishantgarg28152 жыл бұрын
This is the most clean solution I've seen for this problem without creating new nodes. Good job.
@AyushiSharmaDSA2 жыл бұрын
Thank you Nishant :)
@LifestyleSoulDevu2 жыл бұрын
Thanks Ayushi for the series!
@AyushiSharmaDSA2 жыл бұрын
Welcome Devanjali, glad you liked it :)
@aahanaganjewar99512 жыл бұрын
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); } }
@dhanrajlouvanshi78722 жыл бұрын
Special Thanks for Providing java solutions
@AyushiSharmaDSA2 жыл бұрын
Welcome Dhanraj :) Glad it is helpful :)
@soubhikroy99782 жыл бұрын
one more request mam can please discuss leetcode weekly contest question
@AyushiSharmaDSA2 жыл бұрын
Hi Soubhik, yes everytime I think to make video, but then get stuck in some work. I'll surely try :)
@sakshamsengar97982 жыл бұрын
10:22 "otherwise i will make a left kol*******....... call " . highlight of the video 😂😂
@amitsinha8062 жыл бұрын
you are always awesome 😎😎😎😎
@AyushiSharmaDSA2 жыл бұрын
Thanks :)
@rohitraj58322 жыл бұрын
@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; }
@tejaswigutta90172 жыл бұрын
When we backtrack, temp is not updated as it is a local variable. Dry run it once you will understand @rohit raj
@tejaswigutta90172 жыл бұрын
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 :)
@shekharchaugule77002 жыл бұрын
that's great
@AyushiSharmaDSA2 жыл бұрын
Thank you Shekhar :)
@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.
@AyushiSharmaDSA6 ай бұрын
thank you, glad it was helpful😄
@aryangoyal22522 жыл бұрын
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.
@AyushiSharmaDSA2 жыл бұрын
Yeah, first I also thought of doing that, but then I thought it's better to make global variable, this is how we learn :)
@aryangoyal22522 жыл бұрын
@@AyushiSharmaDSA yes mam , i will defineitly keep this in mind from next time.
@ChandraShekhar-by3cd2 жыл бұрын
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??
@AyushiSharmaDSA2 жыл бұрын
Welcome Chandra, Yes, but you can make it global variable as well :)
@ChandraShekhar-by3cd2 жыл бұрын
@@AyushiSharmaDSA Ok, Thanks Ayushi.
@dipanshmalhotra2 жыл бұрын
OP explaination didi helpes a lot (writing smj nhi aai pr approach aagai...XD)
@AyushiSharmaDSA2 жыл бұрын
Thank you Dipansh :) aaj pta ni mouse ko kya hogya, chal hi nhi rha sahi se😂
@amanbhadani88402 жыл бұрын
Too much Easy 🙃
@AyushiSharmaDSA2 жыл бұрын
✌🏻😊
@divine58632 жыл бұрын
Hii Didii.. can you give multiple solutions for problems on leetcode.. so that we can think in broader sense..
@AyushiSharmaDSA2 жыл бұрын
Sure, thanks for valuable feedback. I'll take care from next video onwards 🙂
@markandeysharma97712 жыл бұрын
Mam should I take the course u buyed in 2year for cn???
@AyushiSharmaDSA2 жыл бұрын
The course was good, if you want to buy, you can buy. I took dsa in cpp module
@markandeysharma97712 жыл бұрын
@@AyushiSharmaDSA sure but I going through anuj bhaiya is it okay ??
@AyushiSharmaDSA2 жыл бұрын
@@markandeysharma9771 sorry i haven't seen the content, so can't say anything. :)
@markandeysharma97712 жыл бұрын
@@AyushiSharmaDSA sure
@dipanshmalhotra2 жыл бұрын
eagerly waitinng for new video didi where is new video.
@AyushiSharmaDSA2 жыл бұрын
Hi Dipansh, will upload in some time, sorry for delay :)
@dipanshmalhotra2 жыл бұрын
@@AyushiSharmaDSA koi nhi didi its ok i tried question and finally in the world i solved the trees question:)
@AyushiSharmaDSA2 жыл бұрын
@@dipanshmalhotra awsm🙌🏻🙌🏻🙌🏻🔥
@corporatebhai17032 жыл бұрын
why are we doing node->left=NULL didn't understand
@AyushiSharmaDSA2 жыл бұрын
see because in result tree, for every node, left is null.
@corporatebhai17032 жыл бұрын
@@AyushiSharmaDSA shouldn't we do current->left=null then as that is the tree we are returning
@AyushiSharmaDSA2 жыл бұрын
@@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); }