class Solution { public: bool isToeplitzMatrix(vector<vector<int>>& matrix) { for (int i = 0; i < matrix.size(); ++i) { if (!check(matrix, matrix[i][0], i, 0)) return false; } for (int i = 0; i < matrix[0].size(); ++i) { if (!check(matrix, matrix[0][i], 0, i)) return false; } return true; } bool check(vector<vector<int>>& matrix, int expectVal, int row, int col) { if (row >= matrix.size() || col >= matrix[0].size()) return true; if (matrix[row][col] != expectVal) return false; return check(matrix, expectVal, row + 1, col + 1); } };