We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d449a8a commit 7796a59Copy full SHA for 7796a59
lcof/面试题14- I. 剪绳子/README.md
@@ -183,6 +183,23 @@ public class Solution {
183
}
184
```
185
186
+#### Swift
187
+
188
+```swift
189
+class Solution {
190
+ func cuttingRope(_ n: Int) -> Int {
191
+ var f = [Int](repeating: 0, count: n + 1)
192
+ f[1] = 1
193
+ for i in 2...n {
194
+ for j in 1..<i {
195
+ f[i] = max(f[i], max(f[i - j] * j, (i - j) * j))
196
+ }
197
198
+ return f[n]
199
200
+}
201
+```
202
203
<!-- tabs:end -->
204
205
<!-- solution:end -->
lcof/面试题14- I. 剪绳子/Solution.swift
@@ -0,0 +1,12 @@
1
2
3
4
5
6
7
8
9
10
11
12
0 commit comments