Goldman Sachs interview question

String. Use a freq array