当前位置:网站首页>力扣 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
边栏推荐
- LC: string conversion integer (ATOI) + appearance sequence + longest common prefix
- mysql 的一些重要知识
- JVM 类加载机制
- openEuler 有奖捉虫活动,来参与一下?
- PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!
- 力扣 643. 子数组最大平均数 I
- sql 常用优化
- Some arrangements about oneself
- UCloud是基础云计算服务提供商
- Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference
猜你喜欢
Flink并行度和Slot详解
LeetCode_7_5
8 CAS
Kunpeng developer summit 2022 | Kirin Xin'an and Kunpeng jointly build a new ecosystem of computing industry
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
Make this crmeb single merchant wechat mall system popular, so easy to use!
Ways to improve the utilization of openeuler resources 01: Introduction
vulnhub之tre1
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
2022如何评估与选择低代码开发平台?
随机推荐
2022年投资哪个理财产品收益高?
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
PMP每日一练 | 考试不迷路-7.7
位运算介绍
线性基
【STL】vector
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
mock. JS returns an array from the optional data in the object array
剑指 Offer II 013. 二维子矩阵的和
How to cooperate among multiple threads
Training IX basic configuration of network services
YoloV6:YoloV6+Win10---训练自己得数据集
项目经理『面试八问』,看了等于会了
pom. XML configuration file label: differences between dependencies and dependencymanagement
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置palette参数自定义不同水平小提琴图的填充色、add参数在小提琴图添加箱图
转置卷积理论解释(输入输出大小分析)
equals 方法
【Confluence】JVM内存调整
使用高斯Redis实现二级索引