Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8b3999e

Browse files
feat: add swift implementation to lcof problem: No.04 (doocs#2830)
1 parent 21d3216 commit 8b3999e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

‎lcof/面试题04. 二维数组中的查找/README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,21 @@ public class Solution {
224224
}
225225
```
226226

227+
#### Swift
228+
229+
```swift
230+
class Solution {
231+
func findNumberIn2DArray(_ matrix: [[Int]], _ target: Int) -> Bool {
232+
for row in matrix {
233+
if let _ = row.firstIndex(of: target) {
234+
return true
235+
}
236+
}
237+
return false
238+
}
239+
}
240+
```
241+
227242
<!-- tabs:end -->
228243

229244
<!-- solution:end -->
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
func findNumberIn2DArray(_ matrix: [[Int]], _ target: Int) -> Bool {
3+
for row in matrix {
4+
if let _ = row.firstIndex(of: target) {
5+
return true
6+
}
7+
}
8+
return false
9+
}
10+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /