2025-07-30 10:59:42 +08:00
|
|
|
use std::cmp::max;
|
2025-07-29 11:20:14 +08:00
|
|
|
|
2025-07-10 14:13:01 +08:00
|
|
|
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-30 10:59:42 +08:00
|
|
|
}
|
2025-07-31 11:47:40 +08:00
|
|
|
a == 0 || b == 1
|
2025-07-10 14:13:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2025-07-31 11:47:40 +08:00
|
|
|
let sl = Solution::does_valid_array_exist(vec![1,1,0]);
|
2025-07-29 11:20:14 +08:00
|
|
|
println!("{:?}", sl);
|
2025-07-10 14:13:01 +08:00
|
|
|
}
|