1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-09 15:59:06 +01:00
LeetCode/rs/minimum-number-of-operations-to-make-array-xor-equal-to-k.rs
2024-04-29 21:25:35 +02:00

5 lines
164 B
Rust

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
}
}