diff --git a/rs/minimum-number-of-operations-to-make-array-xor-equal-to-k.rs b/rs/minimum-number-of-operations-to-make-array-xor-equal-to-k.rs new file mode 100644 index 0000000..f7cf86d --- /dev/null +++ b/rs/minimum-number-of-operations-to-make-array-xor-equal-to-k.rs @@ -0,0 +1,5 @@ +impl Solution { + pub fn min_operations(nums: Vec, k: i32) -> i32 { + (k ^ nums.into_iter().reduce(|x, y| x ^ y).unwrap()).count_ones() as i32 + } +}