Goldman Sachs interview question

regular LC question for string/array