当前位置:网站首页>Force buckle 2319 Judge whether the matrix is an X matrix
Force buckle 2319 Judge whether the matrix is an X matrix
2022-07-07 20:06:00 【Tomorrowave】
2319. Judge whether the matrix is a X matrix
If a square matrix satisfies the following All Conditions , It is called a X matrix :
All the elements on the diagonal of the matrix are No 0
All other elements in the matrix are 0
Give you a size of n x n A two-dimensional array of integers grid , Represents a square matrix . If grid It's a X matrix , return true ; otherwise , return false .
Knowledge points involved :
Two dimensional matrix for loop
Code section
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
边栏推荐
- Compiler optimization (4): inductive variables
- Some arrangements about oneself
- [auto.js] automatic script
- 数据孤岛是企业数字化转型遇到的第一道险关
- Detailed explanation of Flink parallelism and slot
- ASP. Net gymnasium integrated member management system source code, free sharing
- vulnhub之Funfox2
- PMP每日一练 | 考试不迷路-7.7
- 实训九 网络服务的基本配置
- Semantic SLAM源码解析
猜你喜欢
PMP practice once a day | don't get lost in the exam -7.7
Welcome to the markdown editor
# 欢迎使用Markdown编辑器
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Some important knowledge of MySQL
ASP. Net learning & ASP's one word
PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
位运算介绍
ASP. Net kindergarten chain management system source code
openEuler 有奖捉虫活动,来参与一下?
随机推荐
R language ggplot2 visualization: use the ggstripchart function of ggpubr package to visualize the dot strip plot, set the position parameter, and configure the separation degree of different grouped
ASP. Net gymnasium integrated member management system source code, free sharing
R语言ggplot2可视化:使用ggpubr包的ggecdf函数可视化分组经验累积密度分布函数曲线、linetype参数指定不同分组曲线的线型
The project manager's "eight interview questions" is equal to a meeting
Notes...
Equals method
LC: string conversion integer (ATOI) + appearance sequence + longest common prefix
mock.js从对象数组中任选数据返回一个数组
PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
第二十章 使用工作队列管理器(三)
模拟实现string类
力扣 88.合并两个有序数组
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
我的创作纪念日
The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
吞吐量Throughout
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
[sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal