Skip to content

Commit 1186fef

Browse files
authored
feat: add cs solution to lc problem: No.0944 (#4912)
1 parent 9955fc2 commit 1186fef

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

solution/0900-0999/0944.Delete Columns to Make Sorted/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,29 @@ impl Solution {
208208
}
209209
```
210210

211+
#### C#
212+
213+
```cs
214+
public class Solution {
215+
public int MinDeletionSize(string[] strs) {
216+
int m = strs[0].Length;
217+
int n = strs.Length;
218+
int ans = 0;
219+
220+
for (int j = 0; j < m; ++j) {
221+
for (int i = 1; i < n; ++i) {
222+
if (strs[i][j] < strs[i - 1][j]) {
223+
++ans;
224+
break;
225+
}
226+
}
227+
}
228+
229+
return ans;
230+
}
231+
}
232+
```
233+
211234
<!-- tabs:end -->
212235

213236
<!-- solution:end -->

solution/0900-0999/0944.Delete Columns to Make Sorted/README_EN.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,29 @@ impl Solution {
211211
}
212212
```
213213

214+
#### C#
215+
216+
```cs
217+
public class Solution {
218+
public int MinDeletionSize(string[] strs) {
219+
int m = strs[0].Length;
220+
int n = strs.Length;
221+
int ans = 0;
222+
223+
for (int j = 0; j < m; ++j) {
224+
for (int i = 1; i < n; ++i) {
225+
if (strs[i][j] < strs[i - 1][j]) {
226+
++ans;
227+
break;
228+
}
229+
}
230+
}
231+
232+
return ans;
233+
}
234+
}
235+
```
236+
214237
<!-- tabs:end -->
215238

216239
<!-- solution:end -->
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class Solution {
2+
public int MinDeletionSize(string[] strs) {
3+
int m = strs[0].Length;
4+
int n = strs.Length;
5+
int ans = 0;
6+
7+
for (int j = 0; j < m; ++j) {
8+
for (int i = 1; i < n; ++i) {
9+
if (strs[i][j] < strs[i - 1][j]) {
10+
++ans;
11+
break;
12+
}
13+
}
14+
}
15+
16+
return ans;
17+
}
18+
}

0 commit comments

Comments
 (0)