Fidelity Investments interview question

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