Dextara Interview Question

They asked me to solve a string based java program.