---
# System prepended metadata

title: 19. Remove Nth Node From End of List
tags: [鏈結串列, LeetCode筆記]

---

# 19. Remove Nth Node From End of List

###### tags: `LeetCode筆記` `鏈結串列`

## 思路：
1. 知道linked list 的travel 
2. 知道邊際值問題
3. leetcode 的head 不用用self.head 


```python=

num=0 
        current=head 

        while current :
            num+=1 
            current=current.next 
        
        position= num-n 
        current_2=head 
        count=1 
        
        if position==0 :
            return head.next 
        
        while current_2: 
            if count==position:
                current_2.next=current_2.next.next 
            current_2=current_2.next 
            count+=1 
        
        return head 
        
```