Block interview question

String manipulation and Matrix traversal