Goldman Sachs interview question

Based on string manipulation and patterns