title: Remove Nth Node From End of List(Leetcode)? - Python
body: <p>Link - <a href="https://leetcode.com/problems/remove-nth-node-from-end-of-list/" rel="nofollow noreferrer">https://leetcode.com/problems/remove-nth-node-from-end-of-list/</a></p>
  
  <p>My approach :</p>
  
  <pre><code>class Solution:
      def removeNthFromEnd(self, head: ListNode, n: int) -&gt; ListNode:
          h = head
          td = h
  
          c = 0
          while head.next is not None:
              c+=1
              print(c,n)
              if c&gt;n:
                  td = td.next
              head = head.next
          if c + 1 != n:
              td.next = td.next.next
          return h
  </code></pre>
  
  <p>It fails in border cases like, [1,2] and n = 2, any way to modify this so that this works for all boarder cases and get accepted? (I know we can solve this using slow and fast pointers)</p>