Medium

Quiz

#449 Serialize and Deserialize BST

APPROACH

Implement a pair of functions that encode a binary search tree to a string and decode the string back to the original BST. Any encoding format is acceptable as long as the round-trip is lossless. Strive for the most compact representation possible.

Example 1:

Input: root = [2,1,3]
Output: [2,1,3]

Example 2:

Input: root = []
Output: []
1 of 4
1:00

What is the optimal approach for this problem?