We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
1 parent 109c602 commit 21d3216Copy full SHA for 21d3216
lcof/面试题03. 数组中重复的数字/README.md
@@ -197,6 +197,22 @@ class Solution {
197
}
198
```
199
200
+#### Swift
201
+
202
+```swift
203
+class Solution {
204
+ func findRepeatNumber(_ nums: [Int]) -> Int {
205
+ let sortedNums = nums.sorted()
206
+ for i in 0..<sortedNums.count - 1 {
207
+ if sortedNums[i] == sortedNums[i + 1] {
208
+ return sortedNums[i]
209
+ }
210
211
+ return -1
212
213
+}
214
+```
215
216
<!-- tabs:end -->
217
218
<!-- solution:end -->
lcof/面试题03. 数组中重复的数字/Solution.swift
@@ -0,0 +1,11 @@
1
2
3
4
5
6
7
8
9
10
11
0 commit comments