Microsoft Interview Question

leetcode question about string and matrix