Merge pull request #2286 from wx05/master

Update 0343.整数拆分.md
This commit is contained in:
程序员Carl
2023-10-02 10:32:02 +08:00
committed by GitHub

View File

@ -469,6 +469,34 @@ object Solution {
}
```
### PHP
```php
class Solution {
/**
* @param Integer $n
* @return Integer
*/
function integerBreak($n) {
if($n == 0 || $n == 1) return 0;
if($n == 2) return 1;
$dp = [];
$dp[0] = 0;
$dp[1] = 0;
$dp[2] = 1;
for($i=3;$i<=$n;$i++){
for($j = 1;$j <= $i/2; $j++){
$dp[$i] = max(($i-$j)*$j, $dp[$i-$j]*$j, $dp[$i]);
}
}
return $dp[$n];
}
}
```
<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>