Microsoft interview question

String manipulation and matrix related math question