3 ms·
Uhh. Only checking for pre-order is incorrect. You need to check both in-order AND pre-order strings. 2 1 / \ \ 1 3 3 The pre-order str
by aloknnikhil 7y ago
Uhh. Only checking for pre-order is incorrect. You need to check both in-order AND pre-order strings.
2 1
/ \ \
1 3 3
The pre-order strings match (213 & 13) but the second tree is not a subtree of the first.
The in-order strings (123 & 13) don't match.