题目:

leetcode 766:托普利茨矩阵

leetcode 766:托普利茨矩阵
算法思想:只需要从第二行第二列开始,和对角线上一个元素比较即可。


代码 :

bool isToeplitzMatrix(vector<vector<int> >& matrix) {
        for(int i = 1;i < matrix.size();i++)
            for(int j = 1;j < matrix[0].size();j++)
            {
                if(matrix[i][j] != matrix[i-1][j-1])
                    return false;
            }
        return true;
}

相关文章:

  • 2021-07-19
  • 2022-12-23
  • 2021-05-12
  • 2021-07-31
  • 2022-12-23
  • 2021-09-03
  • 2021-06-11
猜你喜欢
  • 2021-11-10
  • 2021-11-19
  • 2022-12-23
  • 2022-02-27
  • 2021-10-16
  • 2021-10-06
  • 2022-12-23
相关资源
相似解决方案