Accenture interview question

Coding question based on array and string