Pregunta de entrevista de Connected

1: given a string and a vector which contains words, determine whether the string is valid or not. 2: trees