Skip to content

Commit f151d14

Browse files
committed
Create 1829-maximum-xor-for-each-query.rs
1 parent d74b96a commit f151d14

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

1829-maximum-xor-for-each-query.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub fn get_maximum_xor(nums: Vec<i32>, maximum_bit: i32) -> Vec<i32> {
2+
let max = 2_i32.pow(maximum_bit as u32) - 1;
3+
let mut ret = vec![];
4+
for i in 0..nums.len() {
5+
let mut tmp = max;
6+
for num in &nums[0..nums.len() - i] {
7+
tmp ^= *num;
8+
}
9+
ret.push(tmp);
10+
}
11+
ret
12+
}
13+
14+
fn main() {
15+
let nums = vec![2,3,4,7];
16+
let maximum_bit = 3;
17+
println!("{:?}", get_maximum_xor(nums, maximum_bit));
18+
}

0 commit comments

Comments
 (0)