Pregunta de entrevista de Amazon

Reorganize a string into a specific pattern based on prompt.