Skip to content

Commit e385a55

Browse files
authored
feat: add swift implementation to lcp problem: No.55 (#3788)
1 parent 8f57d8a commit e385a55

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lcp/LCP 55. 采集果实/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ function getMinimumTime(time: number[], fruits: number[][], limit: number): numb
137137
}
138138
```
139139

140+
#### Swift
141+
142+
```swift
143+
class Solution {
144+
func getMinimumTime(_ time: [Int], _ fruits: [[Int]], _ limit: Int) -> Int {
145+
var ans = 0
146+
147+
for fruit in fruits {
148+
let index = fruit[0]
149+
let num = fruit[1]
150+
151+
ans += ((num + limit - 1) / limit) * time[index]
152+
}
153+
154+
return ans
155+
}
156+
}
157+
```
158+
140159
<!-- tabs:end -->
141160

142161
<!-- solution:end -->
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
func getMinimumTime(_ time: [Int], _ fruits: [[Int]], _ limit: Int) -> Int {
3+
var ans = 0
4+
5+
for fruit in fruits {
6+
let index = fruit[0]
7+
let num = fruit[1]
8+
9+
ans += ((num + limit - 1) / limit) * time[index]
10+
}
11+
12+
return ans
13+
}
14+
}

0 commit comments

Comments
 (0)