Goldman Sachs interview question

algorithm on string