Another String Problem

Company: Hsbc

Difficulty: medium