File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed
Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 11---
22title : Sword finger Offer II 021. Delete the countdown of the linked list n Node.md
3- date : ' 2024.01.01 0:00'
3+ date : " 2024.01.01 0:00"
44tags :
55 - - Python
66 - - answer
77abbrlink : 3ed2f01c
8+ docId : qfvqmc1exp066falnsg97c5m
89---
910
1011# topic:
1112
1213[ Sword finger Offer II 021. Delete the countdown of the linked list n Node.md] ( https://leetcode.cn/problems/SLwz0R/description/ )
1314
1415# Thought:
16+
1517Double pointer(Sliding window algorithm)。
1618In this method,We first created a virtual head node dummy,And point it to the original head point head。
1719Then we use two pointers fast and slow,Will fast Poor movement move forward n step。
@@ -21,9 +23,10 @@ at this time,slow pointer指向倒数第 n+1 Node,我们Will其 next pointer
2123at last,We return virtual head nodes next pointer,It points to delete the countdown n Node后的链表的Head node。
2224
2325At the beginning, according toCLinked
26+
2427# Code:
2528
26- ``` python Sliding window algorithm
29+ ``` python Sliding window algorithm
2730class Solution :
2831 def removeNthFromEnd (self , head : Optional[ListNode], n : int ) -> Optional[ListNode]:
2932 # Create a virtual head node
@@ -90,4 +93,4 @@ def list_to_linked_list(lst):
9093 current = current.next
9194
9295 return head
93- ```
96+ ```
Original file line number Diff line number Diff line change 11{
22 "repo" : " InvolutionHell/involutionhell" ,
3- "generatedAt" : " 2025-11-09T14:18:37.524Z " ,
3+ "generatedAt" : " 2025-11-10T03:06:22.583Z " ,
44 "docsDir" : " app/docs" ,
5- "totalDocs" : 107 ,
5+ "totalDocs" : 108 ,
66 "results" : [
77 {
88 "docId" : " ue27z7z95yzw3lhhfj7nit1c" ,
20372037 {
20382038 "docId" : " clx9mmqqvxipdfamqciuo146" ,
20392039 "path" : " app/docs/CommunityShare/Leetcode/2679.矩阵中的和_translated.md" ,
2040+ "contributorStats" : {
2041+ "114939201" : 2
2042+ },
2043+ "contributors" : [
2044+ {
2045+ "githubId" : " 114939201" ,
2046+ "contributions" : 2 ,
2047+ "lastContributedAt" : " 2025-11-09T14:18:38.000Z" ,
2048+ "login" : " longsizhuo" ,
2049+ "avatarUrl" : " https://avatars.githubusercontent.com/u/114939201?v=4" ,
2050+ "htmlUrl" : " https://github.com/longsizhuo"
2051+ }
2052+ ]
2053+ },
2054+ {
2055+ "docId" : " qfvqmc1exp066falnsg97c5m" ,
2056+ "path" : " app/docs/CommunityShare/Leetcode/剑指 Offer II 021. 删除链表的倒数第 n 个结点_translated.md" ,
20402057 "contributorStats" : {
20412058 "114939201" : 1
20422059 },
20432060 "contributors" : [
20442061 {
20452062 "githubId" : " 114939201" ,
20462063 "contributions" : 1 ,
2047- "lastContributedAt" : " 2025-11-09T14:12:37 .000Z" ,
2064+ "lastContributedAt" : " 2025-11-10T03:00:27 .000Z" ,
20482065 "login" : " longsizhuo" ,
20492066 "avatarUrl" : " https://avatars.githubusercontent.com/u/114939201?v=4" ,
20502067 "htmlUrl" : " https://github.com/longsizhuo"
You can’t perform that action at this time.
0 commit comments