当前位置:网站首页>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
边栏推荐
- 微信公众号OAuth2.0授权登录并显示用户信息
- MSE API学习
- pom. XML configuration file label: differences between dependencies and dependencymanagement
- Ucloud is a basic cloud computing service provider
- Nunjuks template engine
- R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化分组点状条带图(dot strip plot)、设置position参数配置不同分组数据点的分离程度
- R language ggplot2 visualization: use the ggqqplot function of ggpubr package to visualize the QQ graph (Quantitative quantitative plot)
- Detailed explanation of Flink parallelism and slot
- IP tools
- R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
猜你喜欢
随机推荐
[RT thread env tool installation]
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
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
SQL common optimization
转置卷积理论解释(输入输出大小分析)
LeetCode_ 7_ five
【Confluence】JVM内存调整
How to cooperate among multiple threads
[confluence] JVM memory adjustment
Ucloud is a basic cloud computing service provider
R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
位运算介绍
Tp6 realize Commission ranking
JVM 类加载机制
力扣 643. 子数组最大平均数 I
Mysql, sqlserver Oracle database connection mode
A pot of stew, a collection of common commands of NPM and yarn cnpm
Cloud component development and upgrading
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記