Nagarro interview question

based on strings and matrix