Pergunta de entrevista da empresa X

I got one question that reduced to graphs/DFS, one string manipulation question, and one SQL question. The first two I got, but the SQL was much more difficult than expected.