mirror of https://github.com/doocs/leetcode.git
feat: add swift implementation to lcp problem: No.06 (#3741)
This commit is contained in:
parent
430ebdc191
commit
83f3c4ede8
|
|
@ -154,6 +154,20 @@ int minCount(int* coins, int coinsSize) {
|
|||
}
|
||||
```
|
||||
|
||||
#### Swift
|
||||
|
||||
```swift
|
||||
class Solution {
|
||||
func minCount(_ coins: [Int]) -> Int {
|
||||
var ans = 0
|
||||
for x in coins {
|
||||
ans += (x + 1) >> 1
|
||||
}
|
||||
return ans
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<!-- tabs:end -->
|
||||
|
||||
<!-- solution:end -->
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
class Solution {
|
||||
func minCount(_ coins: [Int]) -> Int {
|
||||
var ans = 0
|
||||
for x in coins {
|
||||
ans += (x + 1) >> 1
|
||||
}
|
||||
return ans
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue