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 6566514 commit 612c32fCopy full SHA for 612c32f
src/0001-0100/074 - Search a 2D Matrix/search_a_2d_matrix.rs
@@ -0,0 +1,17 @@
1
+impl Solution {
2
+ pub fn search_matrix(matrix: Vec<Vec<i32>>, target: i32) -> bool {
3
+ let (mut rows, mut cols) = (0, matrix[0].len() - 1);
4
+
5
+ while rows < matrix.len() && cols > 0 {
6
+ if matrix[rows][cols] == target {
7
+ return true;
8
+ } else if matrix[rows][cols] > target {
9
+ cols -= 1;
10
+ } else {
11
+ rows += 1;
12
+ }
13
14
15
+ false
16
17
+}
0 commit comments