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

preview_player
Показать описание
Time Complexity : O(n) where n is number of nodes in tree
Space Complexity : O(h) where h is height of tree


Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)

#DataStructuresAndAlgorithms
#BinarySearchTree
#interviewpreparation
Increasing Order Search Tree solution
Increasing Order Search Tree Leetcode
Increasing Order Search Tree C++
Increasing Order Search Tree Java
Increasing Order Search Tree Python

🔥🔥🔥🔥👇👇👇

Checkout the series: 🔥🔥🔥
LIKE | SHARE | SUBSCRIBE 🔥🔥😊
Рекомендации по теме
Комментарии
Автор

mam thanks for regular this type of wonderful content

soubhikroy
Автор

This is the most clean solution I've seen for this problem without creating new nodes. Good job.

nishantgarg
Автор

Tnank you sooo much ..I was stuck in this problem for so many says...You are the first on e to give such a clear solution..

anweshamondal
Автор

Wow, amazing, this is basically converting bst to sorted linked list, So linked list uses dummy node in some problems. Thank you.

iamnoob
Автор

"Didi, your explanation was very clear and helpful. Thank you so much!"

Sai--du
Автор

class Solution {
ArrayList<TreeNode> 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);
}
}

aahanaganjewar
Автор

@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;
}

rohitraj
Автор

one more request mam can please discuss leetcode weekly contest question

soubhikroy
Автор

Special Thanks for
Providing java solutions

dhanrajlouvanshi
Автор

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.

onlydharamsanatandharam
Автор

OP explaination didi helpes a lot (writing smj nhi aai pr approach aagai...XD)

dipanshmalhotra
Автор

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.

aryangoyal
Автор

10:22 "otherwise i will make a left call " . highlight of the video 😂😂

sakshamsengar
Автор

Mam should I take the course u buyed in 2year for cn???

markandeysharma
Автор

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??

ChandraShekhar-bycd
Автор

Hii Didii.. can you give multiple solutions for problems on leetcode.. so that we can think in broader sense..

divine
Автор

why are we doing node->left=NULL didn't understand

corporatebhai
Автор

eagerly waitinng for new video didi where is new video.

dipanshmalhotra
welcome to shbcf.ru