当前位置:网站首页>力扣 2319. 判断矩阵是否是一个 X 矩阵
力扣 2319. 判断矩阵是否是一个 X 矩阵
2022-07-07 17:53:00 【Tomorrowave】
2319. 判断矩阵是否是一个 X 矩阵
如果一个正方形矩阵满足下述 全部 条件,则称之为一个 X 矩阵 :
矩阵对角线上的所有元素都 不是 0
矩阵中所有其他元素都是 0
给你一个大小为 n x n 的二维整数数组 grid ,表示一个正方形矩阵。如果 grid 是一个 X 矩阵 ,返回 true ;否则,返回 false 。

涉及知识点:
二维矩阵的for循环
代码部分
class Solution:
def checkXMatrix(self, grid: List[List[int]]) -> bool:
for i in range(len(grid[0])):
for j in range(len(grid)):
if i==j or len(grid)-j-1==i :
if grid[i][j]==0:
return False
else:
if (grid[i][j]!=0):
return False
return True
边栏推荐
- RESTAPI 版本控制策略【eolink 翻译】
- R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
- The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
- Notes...
- 网信办公布《数据出境安全评估办法》,9 月 1 日起施行
- el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
- 力扣 2315.统计星号
- 【RT-Thread env 工具安装】
- Empowering smart power construction | Kirin Xin'an high availability cluster management system to ensure the continuity of users' key businesses
- MySQL、sqlserver oracle数据库连接方式
猜你喜欢

【STL】vector

ASP. Net kindergarten chain management system source code

PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!

Introduction to bit operation

Cloud 组件发展升级

Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )

J ü rgen schmidhub reviews the 25th anniversary of LSTM papers: long short term memory All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversar

Interpretation of transpose convolution theory (input-output size analysis)

关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】

华南X99平台打鸡血教程
随机推荐
R language ggplot2 visualization: use the ggecdf function of ggpubr package to visualize the grouping experience cumulative density distribution function curve, and the linetype parameter to specify t
2022年投资哪个理财产品收益高?
How to buy stocks on your mobile phone and open an account? Is it safe to open an account
Version selection of boot and cloud
831. KMP字符串
PMP每日一练 | 考试不迷路-7.7
Semantic SLAM源码解析
9 原子操作类之18罗汉增强
Kirin Xin'an won the bid for the new generation dispatching project of State Grid!
Semantic slam source code analysis
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
LC:字符串转换整数 (atoi) + 外观数列 + 最长公共前缀
Throughput
Cloud component development and upgrading
Matplotlib drawing 3D graphics
Cloud 组件发展升级
力扣 1232.缀点成线
关于ssh登录时卡顿30s左右的问题调试处理
微信公众号OAuth2.0授权登录并显示用户信息
[RT thread env tool installation]