Goldman Sachs Interview Question

regular LC question for string/array