EY interview question

One coding question on string