当前位置:网站首页>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
边栏推荐
猜你喜欢
How to cooperate among multiple threads
【STL】vector
项目经理『面试八问』,看了等于会了
力扣 599. 两个列表的最小索引总和
RESTAPI 版本控制策略【eolink 翻译】
Welcome to the markdown editor
Compiler optimization (4): inductive variables
ASP. Net kindergarten chain management system source code
【STL】vector
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
随机推荐
The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
PMP practice once a day | don't get lost in the exam -7.7
Kubernetes——kubectl命令行工具用法详解
MySQL、sqlserver oracle数据库连接方式
Simulate the implementation of string class
9 原子操作类之18罗汉增强
torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
pom.xml 配置文件标签:dependencies 和 dependencyManagement 区别
Cloud 组件发展升级
9 atomic operation class 18 Rohan enhancement
Cuda版本不一致,编译apex报错
CSDN syntax description
力扣674. 最长连续递增序列
Compiler optimization (4): inductive variables
Some arrangements about oneself
Cloud component development and upgrading
浏览积分设置的目的
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
Notes...
力扣 88.合并两个有序数组