rust_test/src/main.rs

20 lines
380 B
Rust
Raw Normal View History

use std::cmp::max;
struct Solution;
impl Solution {
2025-07-31 11:47:40 +08:00
pub fn does_valid_array_exist(derived: Vec<i32>) -> bool {
let mut a = 0;
let mut b = 1;
for i in derived.iter() {
a ^= i;
b ^= i;
}
2025-07-31 11:47:40 +08:00
a == 0 || b == 1
}
}
fn main() {
2025-07-31 11:47:40 +08:00
let sl = Solution::does_valid_array_exist(vec![1,1,0]);
println!("{:?}", sl);
}