File tree 1 file changed +1
-28
lines changed
solution/3500-3599/3548.Equal Sum Grid Partition II
1 file changed +1
-28
lines changed Original file line number Diff line number Diff line change @@ -112,34 +112,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3548.Eq
112
112
#### Python3
113
113
114
114
``` python
115
- from typing import List
116
-
117
- class Solution :
118
- def canPartitionGrid (self , grid : List[List[int ]]) -> bool :
119
- m, n = len (grid), len (grid[0 ])
120
-
121
- total_sum = sum (sum (row) for row in grid)
122
-
123
- # Try horizontal cuts
124
- row_prefix_sum = 0
125
- for i in range (m - 1 ): # cut between row i and i+1
126
- row_prefix_sum += sum (grid[i])
127
- if row_prefix_sum * 2 == total_sum:
128
- return True
129
-
130
- # Try vertical cuts
131
- col_sums = [0 ] * n
132
- for i in range (m):
133
- for j in range (n):
134
- col_sums[j] += grid[i][j]
135
-
136
- col_prefix_sum = 0
137
- for j in range (n - 1 ): # cut between column j and j+1
138
- col_prefix_sum += col_sums[j]
139
- if col_prefix_sum * 2 == total_sum:
140
- return True
141
-
142
- return False
115
+
143
116
```
144
117
145
118
#### Java
You can’t perform that action at this time.
0 commit comments