← Questions
Is a sequence a subsequence of a tree's in-order traversal?
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Given a binary tree and a sequence of numbers, decide whether the sequence appears, in order, within the tree's in-order traversal (not necessarily next to each other). Walk the tree in order and advance a pointer in the sequence on each match. Then do it with no extra space, using Morris traversal. Follow-up: when it is not a subsequence, change the tree as little as possible so that it is.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding
