rs: add «2997. Minimum Number of Operations to Make Array XOR Equal to K»

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-04-29 21:25:35 +02:00
parent 241e5f9aad
commit a55a560f58
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,5 @@
impl Solution {
pub fn min_operations(nums: Vec<i32>, k: i32) -> i32 {
(k ^ nums.into_iter().reduce(|x, y| x ^ y).unwrap()).count_ones() as i32
}
}