← All problemsSign in

1932. Merge BSTs to Create Single BST

LeetCodeArrayHash TableTreeDepth-First SearchBinary Search TreeBinary TreeOpen on judge ↗

You are given n BST (binary search tree) root nodes for n separate BSTs stored in an array trees (0-indexed). Each BST in trees has at most 3 nodes, and no two roots have the same value. In one operation, you can: - Select two distinct indices i and j such that the value stored at one of the leaves of trees[i] is equal to the root value of trees[j]. - Replace the leaf node in trees[i] with trees

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start