Skip to content

Commit 8939602

Browse files
authored
feat: add php solution to lcp problem: No.06 (#1242)
1 parent 68a7041 commit 8939602

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lcp/LCP 06. 拿硬币/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ function minCount(coins: number[]): number {
116116
}
117117
```
118118

119+
### **PHP**
120+
121+
```php
122+
class Solution {
123+
/**
124+
* @param Integer[] $coins
125+
* @return Integer
126+
*/
127+
function minCount($coins) {
128+
$cnt = 0;
129+
for ($i = 0; $i < count($coins); $i++) {
130+
$cnt += floor($coins[$i] / 2) + ($coins[$i] % 2);
131+
}
132+
return $cnt;
133+
}
134+
}
135+
```
136+
119137
### **...**
120138

121139
```

lcp/LCP 06. 拿硬币/Solution.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
/**
3+
* @param Integer[] $coins
4+
* @return Integer
5+
*/
6+
function minCount($coins) {
7+
$cnt = 0;
8+
for ($i = 0; $i < count($coins); $i++) {
9+
$cnt += floor($coins[$i] / 2) + ($coins[$i] % 2);
10+
}
11+
return $cnt;
12+
}
13+
}

0 commit comments

Comments
 (0)