impl Solution {
pub fn remove_nth_from_end(head: Option<Box<ListNode>>, n: i32) -> Option<Box<ListNode>> {
let mut dummy = Some(Box::new(ListNode { val: 0, next: head }));
let mut slow = &mut dummy;
let mut fast = &slow.clone();
for _ in 0..=n {
fast = &fast.as_ref().unwrap().next;
}
while fast.is_some() {
slow = &mut slow.as_mut().unwrap().next;
fast = &fast.as_ref().unwrap().next;
}
let next = slow.as_mut().unwrap().next.as_mut().unwrap().next.take();
slow.as_mut().unwrap().next = next;
dummy.unwrap().next
}
}