1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 01:36:57 +02:00

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