Microsoft Interview Question

String manipulation and matrix related math question