20250114 finished.

This commit is contained in:
jackfiled 2025-01-14 13:02:03 +08:00
parent e42ada3e01
commit 3a314211ed
2 changed files with 40 additions and 0 deletions

View File

@ -430,3 +430,5 @@ mod p3270_find_the_key_of_the_numbers;
mod p2275_largest_combination_with_bitwise_and_greater_than_zero;
mod p2270_number_of_ways_to_split_array;
mod p3065_minimum_operations_to_exceed_threshold_value_i;

View File

@ -0,0 +1,38 @@
/**
* [3065] Minimum Operations to Exceed Threshold Value I
*/
pub struct Solution {}
// submission codes start here
impl Solution {
pub fn min_operations(mut nums: Vec<i32>, k: i32) -> i32 {
nums.sort();
let mut result = 0;
for i in nums {
if i < k {
result += 1;
} else {
break;
}
}
result
}
}
// submission codes end
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_3065() {
assert_eq!(3, Solution::min_operations(vec![2, 11, 10, 1, 3], 10));
assert_eq!(0, Solution::min_operations(vec![1, 1, 2, 4, 9], 1));
assert_eq!(4, Solution::min_operations(vec![1, 1, 2, 4, 9], 9));
}
}