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 83f3c4e

Browse files
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‎

Lines changed: 14 additions & 0 deletions
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‎

Lines changed: 9 additions & 0 deletions
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)

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