-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP766.cpp
More file actions
29 lines (27 loc) · 696 Bytes
/
P766.cpp
File metadata and controls
29 lines (27 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "header.h"
class Solution {
public:
bool isToeplitzMatrix(vector<vector<int>>& matrix) {
if (matrix.empty()) return true;
if (matrix.front().empty()) return true;
int m,n;
m = matrix.size();
n = matrix.front().size();
bool ok = true;
for (int i=0; i<m; i++) {
for (int j=0; j<n; j++) {
int _i, _j;
_i = i+1; _j =j+1;
if (_i>=m || _j >=n) break;
if (matrix[i][j]!=matrix[_i][_j]) {
ok = false;
goto check;
}
}
}
check:return ok;
}
};
int main() {
return 0;
}