Anagrams means "變位字" in Chinese. Assume we have a word "HEART" and we want "HEART" to be the level-order sequence and "EARTH" to be the in-order sequence, the tree would exist. However, if we set "EARTH" to be the level-order sequence and "HEART" to be the in-order sequence, then the tree will not exist. So, your task is to test whether a tree for a given level-order and in-order sequence pair exist or not.
---------------------------------------
Your code only needs to implement solution part.
Your submit code may look like the following.
#include<iostream>
using namespace std;
void solution(char *LevelOrder, char *InOrder)
{
cout << "ABC";
}
First-line contains an integer N.
For the following 2 * N lines the ith line is a level-order sequence and the i+1th line is an In-order sequence.
First line is same as input, which contain a integer.
For the following 2 * N lines will have almost the same format as input, except after each In-order sequence will have permutation sequence and a Yes/No answering the tree exist or not.
Permutation sequence is the corresponding position in the in-order sequence for each number in the level-order sequence.