Superhuman interview question

Some basic string manipulation dsa.