filmov
tv
GFG-POTD | Merge two BST 's using Java | Binary Search Tree | 23 July 2024 | Data Structures
![preview_player](https://i.ytimg.com/vi/ofJQMYzatYE/maxresdefault.jpg)
Показать описание
Geeks-for-Geeks | Practice Problem
23 July 2024
Problem : Merge two BST's using Java
Level : Medium
Language : Java
Topics Tag : Binary Search Tree | Tree | Data Structures | Algorithms
____________________________________________________
Recent GFG Problem Solution :
🧩 1605. Find Valid Matrix Given Row and Column Sums
🧩 Longest alternating subsequences
⬇️ You may also visit my another playlists :
👉 LeetCode Problems :
👉 Code360 by coding ninja's mcq solution :
👉 Geeks-for-Geeks :
----------------------------------------------------------
Stay connected with me on social media for more updates and behind-the-scenes content !
You can find me on 🔍:
📱 Instagram Profile :
🌐 LinkedIn Profile :
-----------------------------------------------------------------
➡️ Problem Statement as follows :
Given two BSTs, return elements of merged BSTs in sorted form.
Examples :
Input:
BST1:
5
/ \
3 6
/ \
2 4
BST2:
2
/ \
1 3
\
7
/
6
Output: 1 2 2 3 3 4 5 6 6 7
Explanation: After merging and sorting the two BST we get 1 2 2 3 3 4 5 6 6 7.
Input:
BST1:
12
/
9
/ \
6 11
BST2:
8
/ \
5 10
/
2
Output: 2 5 6 8 9 10 11 12
Explanation: After merging and sorting the two BST we get 2 5 6 8 9 10 11 12.
Expected Time Complexity: O(m+n)
Expected Auxiliary Space: O(Height of BST1 + Height of BST2 + m + n)
-----------------------------------------
📚 Check out other problems! 🔍:
🧩 1. Partitions with Given Difference | Java | GeekforGeeks | Practice Problem
🧩 2. K-Palindrom | Java | GeeksforGeeks | Practice Problems
🧩 3. [ Part-02 ] Maximum Score Words Formed by Letters - Leetcode
🧩4. Mobile Numeric Keypad :
🧩 5. Boring Factorial ( Coding Ninjas ) :
🧩 6. Coverage of all Zeros in a binary matrix
🧩 7. Make Binary Tree From Linked List :
--------------------------------------------------
#gfgproblems
#gfgsolutions
#gfgproblemoftheday
#gfgtodayproblemoftheday
#mergetwobst
#mergetwobstusingjava
#mergetwobstproblemsolution
#mergetwobstproblemoftheday
#mergetwobstproblemofthedayusingjava
#binarysearchtree
#mergetwobstgfgproblems
#mergetwobstgfgproblemoftheday
23 July 2024
Problem : Merge two BST's using Java
Level : Medium
Language : Java
Topics Tag : Binary Search Tree | Tree | Data Structures | Algorithms
____________________________________________________
Recent GFG Problem Solution :
🧩 1605. Find Valid Matrix Given Row and Column Sums
🧩 Longest alternating subsequences
⬇️ You may also visit my another playlists :
👉 LeetCode Problems :
👉 Code360 by coding ninja's mcq solution :
👉 Geeks-for-Geeks :
----------------------------------------------------------
Stay connected with me on social media for more updates and behind-the-scenes content !
You can find me on 🔍:
📱 Instagram Profile :
🌐 LinkedIn Profile :
-----------------------------------------------------------------
➡️ Problem Statement as follows :
Given two BSTs, return elements of merged BSTs in sorted form.
Examples :
Input:
BST1:
5
/ \
3 6
/ \
2 4
BST2:
2
/ \
1 3
\
7
/
6
Output: 1 2 2 3 3 4 5 6 6 7
Explanation: After merging and sorting the two BST we get 1 2 2 3 3 4 5 6 6 7.
Input:
BST1:
12
/
9
/ \
6 11
BST2:
8
/ \
5 10
/
2
Output: 2 5 6 8 9 10 11 12
Explanation: After merging and sorting the two BST we get 2 5 6 8 9 10 11 12.
Expected Time Complexity: O(m+n)
Expected Auxiliary Space: O(Height of BST1 + Height of BST2 + m + n)
-----------------------------------------
📚 Check out other problems! 🔍:
🧩 1. Partitions with Given Difference | Java | GeekforGeeks | Practice Problem
🧩 2. K-Palindrom | Java | GeeksforGeeks | Practice Problems
🧩 3. [ Part-02 ] Maximum Score Words Formed by Letters - Leetcode
🧩4. Mobile Numeric Keypad :
🧩 5. Boring Factorial ( Coding Ninjas ) :
🧩 6. Coverage of all Zeros in a binary matrix
🧩 7. Make Binary Tree From Linked List :
--------------------------------------------------
#gfgproblems
#gfgsolutions
#gfgproblemoftheday
#gfgtodayproblemoftheday
#mergetwobst
#mergetwobstusingjava
#mergetwobstproblemsolution
#mergetwobstproblemoftheday
#mergetwobstproblemofthedayusingjava
#binarysearchtree
#mergetwobstgfgproblems
#mergetwobstgfgproblemoftheday