Amazon Interview Question

String encryption involving repetition of substrings