Roche interview question

permutation of string, SQL question and another string problem