当前位置:网站首页>766. toplitz matrix
766. toplitz matrix
2022-06-28 01:49:00 【Mr Gao】
766. Toplitz matrix
To give you one m x n Matrix matrix . If this matrix is a Toeplitz matrix , return true ; otherwise , return false .
If every diagonal of a matrix from top left to bottom right has the same element , So what is the matrix Toplitz matrix .
Example 1:
Input :matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
Output :true
explain :
In the above matrix , Its diagonal is :
“[9]”, “[5, 5]”, “[1, 1, 1]”, “[2, 2, 2]”, “[3, 3]”, “[4]”.
All the elements on each diagonal are the same , So the answer is True .
Example 2:
Input :matrix = [[1,2],[2,2]]
Output :false
explain :
Diagonals “[1, 2]” The elements on are different .
The solution code is as follows :
bool isToeplitzMatrix(int** matrix, int matrixSize, int* matrixColSize){
int i;
int n=matrixSize;
int m=matrixColSize[0];
printf("%d %d",n,m);
for(i=0;i<m;i++){
int a=matrix[0][i];
int x=0;
int y=i;
while(x+1<n&&y+1<m){
x=x+1;
y=y+1;
if(matrix[x][y]!=a){
return false;
}
}
}
for(i=0;i<n;i++){
int a=matrix[i][0];
int x=i;
int y=0;
while(x+1<n&&y+1<m){
x=x+1;
y=y+1;
if(matrix[x][y]!=a){
return false;
}
}
}
return true;
}
边栏推荐
- Set collection usage
- 联想拯救者R720如何组建双通道内存
- [Yocto RM]8 - OpenEmbedded Kickstart (.wks) Reference
- Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
- 嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
- style中的scoped属性和lang属性
- How to study efficiently
- What are the requirements for customizing the slip ring for UAV
- . Mp4 video test address
- Intensive reading of transformer thesis paragraph by paragraph
猜你喜欢

Why stainless steel swivel

Solon 1.8.3 release, cloud native microservice development framework

Proe/creo product structure design - continuous research

Overview of drug discovery-01 overview of drug discovery

TI AM3352/54/59 工业核心板硬件说明书

Maimai hot post: Why are big factories keen on making wheels?

Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)

How to optimize the "message" list of IM

How about the market application strength of large-size conductive slip rings

LMSOC:一种对社会敏感的预训练方法
随机推荐
如何阅读一篇论文
Golang monkeys eat peaches and ask for the number of peaches on the first day
awk注意的几个问题
同花顺股票开户是会有什么风险吗?同花顺开户安全吗
Lefse analyzes the local implementation method with all installation files and details to ensure success.
Is there any risk in opening an account for flush stock? Is it safe for flush to open an account
完全二叉树的节点个数[非O(n)求法 -> 抽象二分]
[open source] open source system sorting - Examination Questionnaire, etc
How to study efficiently
Implementation of timed tasks in laravel framework
Hi, you have a code review strategy to check!
Cloud assisted privacy collection intersection (server assisted psi) protocol introduction: Learning
Deepmind | pre training of molecular property prediction through noise removal
Interviewer asked: Inheritance of JS
TD Hero 线上发布会|7月2日邀你来
机器学习笔记 - 时间序列作为特征
Is it safe to open an online futures account?
【嵌入式基础】内存(Cache,RAM,ROM,Flash)
【牛客討論區】第四章:Redis
网络爬虫是什么