We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2dd8ca2 commit 411b6bfCopy full SHA for 411b6bf
lcof2/剑指 Offer II 088. 爬楼梯的最少成本/README.md
@@ -235,6 +235,23 @@ function minCostClimbingStairs(cost: number[]): number {
235
}
236
```
237
238
+#### Swift
239
+
240
+```swift
241
+class Solution {
242
+ func minCostClimbingStairs(_ cost: [Int]) -> Int {
243
+ var a = 0
244
+ var b = 0
245
+ for i in 1..<cost.count {
246
+ let c = min(a + cost[i - 1], b + cost[i])
247
+ a = b
248
+ b = c
249
+ }
250
+ return b
251
252
+}
253
+```
254
255
<!-- tabs:end -->
256
257
<!-- solution:end -->
lcof2/剑指 Offer II 088. 爬楼梯的最少成本/Solution2.swift
@@ -0,0 +1,12 @@
1
2
3
4
5
6
7
8
9
10
11
12
0 commit comments