1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// @Title: 在排序数组中查找数字 I (在排序数组中查找数字  LCOF)
// @Author: 15816537946@163.com
// @Date: 2022-02-03 11:45:44
// @Runtime: 0 ms
// @Memory: 2.3 MB
impl Solution {
    pub fn search(nums: Vec<i32>, target: i32) -> i32 {
        nums.iter()
            .fold(0, |c, &n| if n == target { c + 1 } else { c })
    }
}