Google interview question

dp question involving matrix was asked