mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 15:09:40 +08:00
@ -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"/>
|
||||
|
Reference in New Issue
Block a user