was able to solve this one on my own,... you are an inspiration, I wait for your video and this helps me in finding my consistensy Ayushi,. Kusdos to you and your efforts:D
@AyushiSharmaDSA
2 ай бұрын
thank you so much Yash. This motivates me a lot❤
@pulkitkogta2807
2 ай бұрын
I was trying to use sum as a function parameter and got stuck. But why it can't be solved that way?
@naveenalla3000
2 ай бұрын
clear explanation good
@AyushiSharmaDSA
2 ай бұрын
Glad you think so! thank you :)
@SHIVAMKUMAR-ud4no
2 ай бұрын
Great explanation... Are you on notice period, which company are you going to join?
@AyushiSharmaDSA
2 ай бұрын
thank you :) I was on notice period. I have joined microsoft :)
@SHIVAMKUMAR-ud4no
2 ай бұрын
Thanks for reply mam.
@JayantKumar-lq9lg
2 ай бұрын
btw we are from the same batch, and you are doing very well 👏👏
@Karansingh_78
2 ай бұрын
Ma'am, what is the best way to improve problem-solving skills? Should I watch a video and then solve the problem? Can you please help by explaining the steps you followed?
@AyushiSharmaDSA
2 ай бұрын
Hi Karan, I will suggest try to think solution of a problem for around 10-15 mins (atleast brute force) and then check solution if not able to get to optimal approach :)
@Karansingh_78
2 ай бұрын
@@AyushiSharmaDSA thank you, Ma'am, for the suggestions. I'm currently working at a small startup and graduated in 2022. How can I switch to a big MNC? what are steps i should follow?
@JayantKumar-lq9lg
2 ай бұрын
Also, I'm going to solve the same problem 😁
@rahulbains9409
2 ай бұрын
Good solution, but seems like the only one I am trying to figure out an approach which I am generally used to rather than using a global variable is there a way to add the sum to a helperfunction and then get the solution?
@AshutoshKumar-es8xy
2 ай бұрын
yes there is class Solution { public TreeNode bstToGst(TreeNode root) { dfs(root, 0); return root; } public int dfs(TreeNode root, int sum) { if (root == null) return 0; var val = root.val; var right = dfs(root.right, sum); root.val += sum + right; return val + dfs(root.left, root.val) + right; } }
@AyushiSharmaDSA
2 ай бұрын
thank you for sharing code and helping others :)
@rahulbains9409
2 ай бұрын
@@AshutoshKumar-es8xy Thanks for this bro
@178patilpruthviraj7
2 ай бұрын
I tried following approach and it executed successfully , Can you tell me this solution effiecient or not ? void inorder(struct TreeNode* root, struct TreeNode **hash) { if(root != NULL) { hash[root->val] = root; inorder(root->left, hash); inorder(root->right, hash); } } struct TreeNode* bstToGst(struct TreeNode* root) { struct TreeNode **hash = (struct TreeNode**)calloc(100 , sizeof(struct TreeNode*)); int sum = 0; inorder(root, hash); for(int i=99; i>=0; i--) { if(hash[i] != NULL) { sum += hash[i]->val; hash[i]->val = sum; } } free(hash); return root; }
@097mazharsaifi8
2 ай бұрын
well explained btw mam you missed the yesterday potd video...
@AyushiSharmaDSA
2 ай бұрын
Hi, yes. Was not well yesterday. Will post that too :)
@097mazharsaifi8
2 ай бұрын
@@AyushiSharmaDSA get well soon mam and You are doing a great work by helping your juniors ...Thankyou so much for guiding us...😊
Пікірлер: 25