fn remove_adjacent_pair(s: &str) -> String {
let mut s = s.to_string();
let mut i = 0;
while i < s.len() - 1 {
if s.as_bytes()[i] == s.as_bytes()[i + 1] {
s.remove(i);
s.remove(i);
if i != 0 {
i -= 1;
}
} else {
i += 1;
}
}
s
}
fn main() {
let s = "aabcccdeeffffgac";
let s = remove_adjacent_pair(s);
println!("{}", s);
}
/*
run:
bcdgac
*/