Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fddab1a

Browse files
committed
Update 0474.一和零,添加C#
1 parent e0b0078 commit fddab1a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎problems/0474.一和零.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,33 @@ impl Solution {
533533
}
534534
}
535535
```
536+
### C#
537+
```csharp
538+
public class Solution
539+
{
540+
public int FindMaxForm(string[] strs, int m, int n)
541+
{
542+
int[,] dp = new int[m + 1, n + 1];
543+
foreach (string str in strs)
544+
{
545+
int zero = 0, one = 0;
546+
foreach (char c in str)
547+
{
548+
if (c == '0') zero++;
549+
else one++;
550+
}
551+
for (int i = m; i >= zero; i--)
552+
{
553+
for (int j = n; j >= one; j--)
554+
{
555+
dp[i, j] = Math.Max(dp[i, j], dp[i - zero, j - one] + 1);
556+
}
557+
}
558+
}
559+
return dp[m, n];
560+
}
561+
}
562+
```
536563

537564
<p align="center">
538565
<a href="https://programmercarl.com/other/kstar.html" target="_blank">

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /