Amazon Interview Question

They asked me a leetcode style question based on string manipulation and arrays.