Insi interview question

It was a Hackerrank coding challenge