Accenture Interview Question

Question from DSA- array, string