Update 0343.整数拆分,添加C#
This commit is contained in:
parent
08617fdff7
commit
0076152aec
|
|
@ -496,6 +496,25 @@ class Solution {
|
|||
}
|
||||
}
|
||||
```
|
||||
### C#
|
||||
```csharp
|
||||
public class Solution
|
||||
{
|
||||
public int IntegerBreak(int n)
|
||||
{
|
||||
int[] dp = new int[n + 1];
|
||||
dp[2] = 1;
|
||||
for (int i = 3; i <= n; i++)
|
||||
{
|
||||
for (int j = 1; j <= i / 2; j++)
|
||||
{
|
||||
dp[i] = Math.Max(dp[i],Math.Max(j*(i-j),j*dp[i-j]));
|
||||
}
|
||||
}
|
||||
return dp[n];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
|
|
|
|||
Loading…
Reference in New Issue