Google Interview Question

Matrix question and something with loops