20250202 finished.

This commit is contained in:
jackfiled 2025-02-02 16:37:18 +08:00
parent cdbf7d074f
commit f3fd9ab5d1
2 changed files with 53 additions and 0 deletions

View File

@ -464,3 +464,5 @@ mod p350_intersection_of_two_arrays_ii;
mod p541_reverse_string_ii;
mod p81_search_in_rotated_sorted_array_ii;
mod p598_range_addition_ii;

View File

@ -0,0 +1,51 @@
/**
* [598] Range Addition II
*/
pub struct Solution {}
// submission codes start here
impl Solution {
pub fn max_count(mut m: i32, mut n: i32, ops: Vec<Vec<i32>>) -> i32 {
for array in ops {
m = m.min(array[0]);
n = n.min(array[1]);
}
m * n
}
}
// submission codes end
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_598() {
assert_eq!(4, Solution::max_count(3, 3, vec![vec![2, 2], vec![3, 3]]));
assert_eq!(
4,
Solution::max_count(
3,
3,
vec![
vec![2, 2],
vec![3, 3],
vec![3, 3],
vec![3, 3],
vec![2, 2],
vec![3, 3],
vec![3, 3],
vec![3, 3],
vec![2, 2],
vec![3, 3],
vec![3, 3],
vec![3, 3]
]
)
);
assert_eq!(9, Solution::max_count(3, 3, vec![]));
}
}