Skip to content

Commit 1d606ba

Browse files
add 960
1 parent 0edc957 commit 1d606ba

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ LeetCode
253253
|0957|[Prison Cells After N Days](https://leetcode.com/problems/prison-cells-after-n-days/) | c | [c++](./src/0957-Prison-Cells-After-N-Days/0957.cpp) |[python](./src/0957-Prison-Cells-After-N-Days/0957.py)|||Medium|
254254
|0958|[Check Completeness of a Binary Tree](https://leetcode.com/problems/check-completeness-of-a-binary-tree/) | c | [c++](./src/0958-Check-Completeness-of-a-Binary-Tree/0958.cpp) |[python](./src/0958-Check-Completeness-of-a-Binary-Tree/0958.py)|||Medium|
255255
|0959|[Regions Cut By Slashes](https://leetcode.com/problems/regions-cut-by-slashes/) | c | [c++](./src/0959-Regions-Cut-By-Slashes/0959.cpp) |[python](./src/0959-Regions-Cut-By-Slashes/0959.py)|||Medium|
256+
|0960|[Delete Columns to Make Sorted III](https://leetcode.com/problems/delete-columns-to-make-sorted-iii/) | c | [c++](./src/0960-Delete-Columns-to-Make-Sorted-III/0960.cpp) |[python](./src/0960-Delete-Columns-to-Make-Sorted-III/0960.py)|||Hard|
256257
|0961|[N-Repeated Element in Size 2N Array](https://leetcode.com/problems/n-repeated-element-in-size-2n-array/) | c | [c++](./src/0961-N-Repeated-Element-in-Size-2N-Array/0961.cpp) |[python](./src/0961-N-Repeated-Element-in-Size-2N-Array/0961.py)|||Easy|
257258
|0962|[Maximum Width Ramp](https://leetcode.com/problems/maximum-width-ramp/) | c | [c++](./src/0962-Maximum-Width-Ramp/0962.cpp) |[python](./src/0962-Maximum-Width-Ramp/0962.py)|||Medium|
258259
|0963|[Minimum Area Rectangle II](https://leetcode.com/problems/minimum-area-rectangle-ii/) | c | [c++](./src/0963-Minimum-Area-Rectangle-II/0963.cpp) |[python](./src/0963-Minimum-Area-Rectangle-II/0963.py)|||Medium|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
static int x = []() {std::ios::sync_with_stdio(false); cin.tie(0); return 0; }();
2+
class Solution
3+
{
4+
public:
5+
int minDeletionSize(vector<string>& A)
6+
{
7+
vector<int> mem(A[0].size(), 1);
8+
for (int i = 0; i < A[0].size(); ++i)
9+
{
10+
for (int j = 0; j < i; ++j)
11+
{
12+
for (int k = 0; k <= A.size(); ++k)
13+
{
14+
if (k == A.size()) mem[i] = max(mem[i], mem[j] + 1);
15+
else if (A[k][j] > A[k][i]) break;
16+
}
17+
}
18+
}
19+
return A[0].size() - *max_element(begin(mem), end(mem));
20+
}
21+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
def minDeletionSize(self, A):
3+
"""
4+
:type A: List[str]
5+
:rtype: int
6+
"""
7+
r, c = len(A), len(A[0])
8+
mem = [1] * c
9+
for i in range(1, c):
10+
for j in range(i):
11+
for k in range(r+1):
12+
if k == r:
13+
mem[i] = max(mem[i], mem[j] + 1)
14+
elif A[k][j] > A[k][i]:
15+
break
16+
17+
return c - max(mem)

0 commit comments

Comments
 (0)