1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// @Title: 二维数组中的查找 (二维数组中的查找 LCOF)
// @Author: 15816537946@163.com
// @Date: 2022-02-07 22:37:16
// @Runtime: 0 ms
// @Memory: 2.5 MB
// struct Solution;
impl Solution {
    pub fn find_number_in2_d_array(matrix: Vec<Vec<i32>>, target: i32) -> bool {
        matrix.iter().flat_map(|v| v.iter()).any(|&p| p == target)
        // matrix.iter().flat_map(|v| v.iter()).any(|&p| p == target)
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_case1() {
        assert_eq!(Solution::find_number_in2_d_array(vec![vec![5]], -10), false);
    }
}