2319. Check if Matrix Is X-Matrix
599. Minimum Index Sum of Two Lists
674. Longest Continuous Increasing Subsequence
989. Add to Array-Form of Integer
第一题 2319
(1)暴力求解,两个循环遍历二维数组下标
(2)两次判断,对角线元素为零时false,非对角线元素不为零时false
注意
起初因为思考方向是先return true而纠结了很久
先return判断条件较少的结果
class Solution {
public:
bool checkXMatrix(vector<vector<int>>& grid) {
for(int i = 0; i<grid.size(); i++){
for(int j = 0; j<grid.size(); j++){
if(i == j || i+j == grid.size()-1){
if(grid[i][j] == 0){
return false;
}
}
else if(grid[i][j]