Skip to content

Commit 83f3c4e

Browse files
authored
feat: add swift implementation to lcp problem: No.06 (#3741)
1 parent 430ebdc commit 83f3c4e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

+14
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ int minCount(int* coins, int coinsSize) {
154154
}
155155
```
156156
157+
#### Swift
158+
159+
```swift
160+
class Solution {
161+
func minCount(_ coins: [Int]) -> Int {
162+
var ans = 0
163+
for x in coins {
164+
ans += (x + 1) >> 1
165+
}
166+
return ans
167+
}
168+
}
169+
```
170+
157171
<!-- tabs:end -->
158172

159173
<!-- solution:end -->

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

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution {
2+
func minCount(_ coins: [Int]) -> Int {
3+
var ans = 0
4+
for x in coins {
5+
ans += (x + 1) >> 1
6+
}
7+
return ans
8+
}
9+
}

0 commit comments

Comments
 (0)