Dextara interview question

They asked me to solve a string based java program.