Skip to content

Commit 8319528

Browse files
committed
src/bin/check-if-grid-satisfies-conditions.rs
1 parent b72e1be commit 8319528

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![allow(dead_code, unused, unused_variables, non_snake_case)]
2+
3+
fn main() {}
4+
5+
struct Solution;
6+
7+
impl Solution {
8+
pub fn satisfies_conditions(grid: Vec<Vec<i32>>) -> bool {
9+
for i in 0..grid.len() {
10+
for j in 0..grid[0].len() {
11+
if let Some(Some(&x)) = grid.get(i + 1).map(|c| c.get(j)) {
12+
if x != grid[i][j] {
13+
return false;
14+
}
15+
}
16+
17+
if let Some(Some(&x)) = grid.get(i).map(|c| c.get(j + 1)) {
18+
if x == grid[i][j] {
19+
return false;
20+
}
21+
}
22+
}
23+
}
24+
25+
true
26+
}
27+
}

0 commit comments

Comments
 (0)