mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Update 0343.整数拆分,添加C#
This commit is contained in:
@ -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">
|
<p align="center">
|
||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
|
Reference in New Issue
Block a user