Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7_homework_yangpeng
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨鹏
7_homework_yangpeng
Commits
fc91be71
Commit
fc91be71
authored
Jan 20, 2019
by
yangpengflag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
toeplitzmatrix.py
+38
-0
No files found.
toeplitzmatrix.py
0 → 100644
View file @
fc91be71
class
Solution
:
def
isToeplitzMatrix
(
self
,
matrix
):
pass
"""
:type matrix: List[List[int]]
:rtype: bool
解题思路:遍历每一个元素,同时比较这个元素和它右下角元素的值是否相等,如果不相等,直接返回false,停止遍历
"""
for
i
in
range
(
len
(
matrix
)
-
1
):
for
j
in
range
(
len
(
matrix
[
i
])
-
1
):
if
(
matrix
[
i
+
1
][
j
+
1
]
!=
matrix
[
i
][
j
]):
return
False
return
True
if
__name__
==
"__main__"
:
solution
=
Solution
()
matrix
=
[
[
1
,
2
],
[
2
,
2
]
]
print
(
solution
.
isToeplitzMatrix
(
matrix
))
matrix
=
[
[
1
,
2
,
3
,
4
],
[
5
,
1
,
2
,
3
],
[
9
,
5
,
1
,
2
]
]
print
(
solution
.
isToeplitzMatrix
(
matrix
))
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment