/**
* @param ListNode $head
* @param Integer $n
* @return ListNode
*/
function removeNthFromEnd($head, $n) {
if($head == null){
return $head;
}
$newList = new ListNode();
$newList->next = $head;
$fast = $slow = $newList;
for($i=0; $i<$n+1; $i++){
$fast = $fast->next;
}
while($fast != null){
$fast = $fast->next;
$slow = $slow->next;
}
$slow->next = $slow->next->next;
return $newList->next;
}