← ALL NOTES
Array

1569. Number of Ways to Reorder Array to Get Same BST

The root never moves. Whatever nums[0] is, it has to come first in every valid reordering, and then every value below it falls into the left subtree and every value above it into the right, each keeping the relative order it had in the original array. The subtrees' internal orders are frozen. The only thing I get to choose is how the two blocks interleave.

Loading…