Skip to content

Commit 6fe5d43

Browse files
committedMar 11, 2020
2020-03-10
1 parent 3f041a7 commit 6fe5d43

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed
 

‎1013.将数组分成和相等的三个部分/1013-将数组分成和相等的三个部分.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ def canThreePartsEqualSum(self, A):
44
:type A: List[int]
55
:rtype: bool
66
"""
7-
# from collections import defaultdict
87
target = sum(A) // 3
98
snow = 0
109
cnt = 0
@@ -13,4 +12,4 @@ def canThreePartsEqualSum(self, A):
1312
if target == snow:
1413
snow = 0
1514
cnt += 1
16-
return cnt == 3
15+
return cnt >= 3
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution(object):
2+
def add(self, a, b):
3+
"""
4+
:type a: int
5+
:type b: int
6+
:rtype: int
7+
"""
8+
return sum([a, b])
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution(object):
2+
def setZeroes(self, matrix):
3+
"""
4+
:type matrix: List[List[int]]
5+
:rtype: None Do not return anything, modify matrix in-place instead.
6+
"""
7+
if not matrix or not matrix[0]:
8+
return matrix
9+
10+
m, n = len(matrix), len(matrix[0])
11+
12+
row0, col0 = set(), set()
13+
14+
for i in range(m):
15+
for j in range(n):
16+
if not matrix[i][j]:
17+
row0.add(i)
18+
col0.add(j)
19+
20+
for i in range(m):
21+
for j in range(n):
22+
if i in row0 or j in col0:
23+
matrix[i][j] = 0
24+
25+
return matrix

0 commit comments

Comments
 (0)
Please sign in to comment.