We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5365e1e commit 3a84536Copy full SHA for 3a84536
lcof/面试题63. 股票的最大利润/README.md
@@ -174,6 +174,24 @@ public class Solution {
174
}
175
```
176
177
+#### Swift
178
+
179
+```swift
180
+class Solution {
181
+ func maxProfit(_ prices: [Int]) -> Int {
182
+ var mi = Int.max
183
+ var ans = 0
184
185
+ for x in prices {
186
+ ans = max(ans, x - mi)
187
+ mi = min(mi, x)
188
+ }
189
190
+ return ans
191
192
+}
193
+```
194
195
<!-- tabs:end -->
196
197
<!-- solution:end -->
lcof/面试题63. 股票的最大利润/Solution.swift
@@ -0,0 +1,13 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
0 commit comments