Uber interview question

String matrix manipulations and string