HackerRank interview question

Related to string manipulation and implementation