We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4973492 commit 83a941fCopy full SHA for 83a941f
lcof/面试题42. 连续子数组的最大和/README.md
@@ -189,6 +189,24 @@ public class Solution {
189
}
190
```
191
192
+#### Swift
193
+
194
+```swift
195
+class Solution {
196
+ func maxSubArray(_ nums: [Int]) -> Int {
197
+ var ans = Int.min
198
+ var currentSum = 0
199
200
+ for x in nums {
201
+ currentSum = max(currentSum, 0) + x
202
+ ans = max(ans, currentSum)
203
+ }
204
205
+ return ans
206
207
+}
208
+```
209
210
<!-- tabs:end -->
211
212
<!-- solution:end -->
lcof/面试题42. 连续子数组的最大和/Solution.swift
@@ -0,0 +1,13 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
0 commit comments