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 afc9e07

Browse files
authored
Update 0343.整数拆分.md
新增0343.整数拆分.md PHP 版本
1 parent 97587fb commit afc9e07

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎problems/0343.整数拆分.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,34 @@ object Solution {
469469
}
470470
```
471471

472+
473+
### PHP
474+
```php
475+
class Solution {
476+
477+
/**
478+
* @param Integer $n
479+
* @return Integer
480+
*/
481+
function integerBreak($n) {
482+
if($n == 0 || $n == 1) return 0;
483+
if($n == 2) return 1;
484+
485+
$dp = [];
486+
$dp[0] = 0;
487+
$dp[1] = 0;
488+
$dp[2] = 1;
489+
for($i=3;$i<=$n;$i++){
490+
for($j = 1;$j <= $i/2; $j++){
491+
$dp[$i] = max(($i-$j)*$j, $dp[$i-$j]*$j, $dp[$i]);
492+
}
493+
}
494+
495+
return $dp[$n];
496+
}
497+
}
498+
```
499+
472500
<p align="center">
473501
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
474502
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>

0 commit comments

Comments
(0)

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