Fidelity Investments Interview Question

Solve a string splicing problem in Java and Python (had to use both languages)