-
Notifications
You must be signed in to change notification settings - Fork 0
/
range-addition-ii.rs
50 lines (47 loc) · 1.17 KB
/
range-addition-ii.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#![allow(unused)]
struct Solution;
impl Solution {
pub fn max_count(mut m: i32, mut n: i32, mut ops: Vec<Vec<i32>>) -> i32 {
ops = ops
.into_iter()
.map(|x| {
m = m.min(x[0]);
n = n.min(x[1]);
x
})
.collect::<Vec<_>>();
m * n
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn max_count() {
assert_eq!(Solution::max_count(3, 3, vec![vec![2, 2], vec![3, 3]]), 4);
assert_eq!(Solution::max_count(3, 3, vec![]), 9);
assert_eq!(
Solution::max_count(
26,
17,
vec![
vec![20, 10],
vec![26, 11],
vec![2, 11],
vec![4, 16],
vec![2, 3],
vec![23, 13],
vec![7, 15],
vec![11, 11],
vec![25, 13],
vec![11, 13],
vec![13, 11],
vec![13, 16],
vec![26, 17]
]
),
6
);
}
}
fn main() {}