⚡️Beat 100.00% | ✅ Full explanation with pictures 🧩
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Code\nPython []\nclass Solution(object):\n    def removeNthFromEnd(self, head, n):\n        dummy = ListNode(0)\n        d
![Screen Shot 2024-03-14 at 11.30.19.png](https://assets.leetcode.com/users/images/99fe0b15-b318-4601-af0f-574bc98640ee_1710652249.4421208.png)\n\n![Screen Shot 2024-03-03 at 10.36.36.png](https://assets.leetcode.com/users/images/b7d26c5d-11c9-442e-be45-d34d29e8f934_1709444229.46226.png)\n\n\n![Glenn Radars_7.png](https://assets.leetcode.com/users/images/a497d0b1-b512-40b1-9bca-4cbcaeb6befd_1709339631.914102.png)\n\n![Glenn Radars_8.png](https://assets.leetcode.com/users/images/4181a9e5-4176-4220-b760-db3bec2dc49f_1709342661.0236943.png)\n\n![Glenn Radars_4.png](https://assets.leetcode.com/users/images/2ea28b78-3d44-4f39-8ceb-9e03f58fa6f9_1709429063.4852471.png)\n\n![Glenn Radars_4 4.png](https://assets.leetcode.com/users/images/bfc049a0-882b-40eb-8d51-6f403a706dc3_1709429078.5670192.png)\n\n![Glenn Radars_4 5.png](https://assets.leetcode.com/users/images/bc2d6978-1908-41fe-a2f5-c072df4c334f_1709429087.5657835.png)\n\n![Glenn Radars_4 6.png](https://assets.leetcode.com/users/images/ebede831-5e77-473a-9221-21a5d57a7824_1709429108.9850168.png)\n\n\n# Code\n```Python []\nclass Solution(object):\n    def removeNthFromEnd(self, head, n):\n        dummy = ListNode(0)\n        dummy.next = head\n        first = dummy\n        second = dummy\n\n        for _ in range(n + 1):\n            first = first.next\n\n        while first is not None:\n            first = first.next\n            second = second.next\n\n        second.next = second.next.next\n\n        return dummy.next\n```\n```python3 []\nclass Solution:\n    def removeNthFromEnd(self, head: Optional[ListNode], n: int) -> Optional[ListNode]:\n        dummy = ListNode(0)\n        dummy.next = head\n        first = dummy\n        second = dummy\n\n        for _ in range(n + 1):\n            first = first.next\n\n        while first is not None:\n            first = first.next\n            second = second.next\n\n        second.next = second.next.next\n\n        return dummy.next\n```\n```C++ []\nclass Solution {\npublic:\n    ListNode* removeNthFromEnd(ListNode* head, int n) {\n        ListNode* dummy = new ListNode(0);\n        dummy->next = head;\n        ListNode* first = dummy;\n        ListNode* second = dummy;\n\n        for (int i = 0; i <= n; ++i) {\n            first = first->next;\n        }\n\n        while (first != nullptr) {\n            first = first->next;\n            second = second->next;\n        }\n\n        ListNode* temp = second->next;\n        second->next = second->next->next;\n        delete temp;\n\n        return dummy->next;\n    }\n};\n```\n```javascript []\nvar removeNthFromEnd = function(head, n) {\n    const dummy = new ListNode(0);\n    dummy.next = head;\n    let first = dummy;\n    let second = dummy;\n\n    for (let i = 0; i <= n; i++) {\n        first = first.next;\n    }\n\n    while (first !== null) {\n        first = first.next;\n        second = second.next;\n    }\n\n    second.next = second.next.next;\n\n    return dummy.next;\n};\n```\n![Screen Shot 2024-03-14 at 11.30.19.png](https://assets.leetcode.com/users/images/99fe0b15-b318-4601-af0f-574bc98640ee_1710652249.4421208.png)\n\n## **My solutions**\n\n\uD83D\uDFE2 - $$easy$$  \n\uD83D\uDFE1 - $$medium$$ \n\uD83D\uDD34 - $$hard$$\n\n\uD83D\uDFE1 [17. Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/solutions/4845532/there-is-an-80-chance-of-being-in-the-interview-full-problem-explanation)\n\uD83D\uDFE1 [22. Generate Parentheses](https://leetcode.com/problems/generate-parentheses/solutions/4845742/simple-explanation-with-pictures)\n\uD83D\uDFE1 [39. Combination Sum](https://leetcode.com/problems/combination-sum/solutions/4847482/beat-8292-full-explanation-with-pictures)\n\uD83D\uDFE2 [2540. Minimum Common Value](https://leetcode.com/problems/minimum-common-value/solutions/4845076/beat-9759-full-explanation-with-pictures)\n\uD83D\uDFE2 [3005. Count Elements With Maximum Frequency](https://leetcode.com/problems/count-elements-with-maximum-frequency/solutions/4839796/beat-8369-full-explanation-with-pictures)\n\uD83D\uDFE2 [3028. Ant on the Boundary](https://leetcode.com/problems/ant-on-the-boundary/solutions/4837433/full-explanation-with-pictures)\n\uD83D\uDFE2 [876. Middle of the Linked List](https://leetcode.com/problems/middle-of-the-linked-list/solutions/4834682/beat-10000-full-explanation-with-pictures)\n\uD83D\uDFE1 [1750. Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends/solutions/4824224/beat-10000-full-explanation-with-pictures)\n\uD83D\uDFE1 [948. Bag of Tokens](https://leetcode.com/problems/bag-of-tokens/solutions/4818912/beat-10000-full-explanation-with-pictures)\n\uD83D\uDFE1 [19. Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/solutions/4813340/beat-10000-full-explanation-with-pictures)\n\uD83D\uDFE2 [977. Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array/solutions/4807704/square-sorter-python-python3-javascript-c)\n\uD83D\uDFE2 [2864. Maximum Odd Binary Number](https://leetcode.com/problems/maximum-odd-binary-number/solutions/4802402/visual-max-odd-binary-solver-python-python3-javascript-c)\n\uD83D\uDFE1 [1609. Even Odd Tree](https://leetcode.com/problems/even-odd-tree/solutions/4797529/even-odd-tree-validator-python-python3-javascript-c)\n\uD83D\uDFE2 [9. Palindrome Number](https://leetcode.com/problems/palindrome-number/solutions/4795373/why-not-1-line-of-code-python-python3-c-everyone-can-understand)\n\uD83D\uDFE1 [513. Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value/solutions/4792022/binary-tree-explorer-mastered-javascript-python-python3-c-10000-efficiency-seeker)\n\uD83D\uDFE2 [1. Two Sum](https://leetcode.com/problems/two-sum/solutions/4791305/5-methods-python-c-python3-from-easy-to-difficult)\n\uD83D\uDFE2 [543. Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/solutions/4787634/surpassing-9793-memory-magician-excelling-at-9723)\n[More...](https://leetcode.com/DevOgabek/)\n\n
['Linked List', 'Two Pointers', 'Python', 'C++', 'Python3', 'JavaScript']