Google Interview Question

Matrix-related problem - trying to solve it in O(1)