Accenture interview question

Question from DSA- array, string