leetcode 19. Remove Nth Node From End of List
来源:互联网 发布:软件测试工程师职责 编辑:程序博客网 时间:2024/06/05 14:25
其实三个指针可以简化称为两个,要删除的元素不需要指针,只需要记录其后面元素的指针,最后到达应该删除的位置之后:
back -> next = back->next->next;
ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode * front = head, * rem = head, * back = head; int m = n-1; while(m--){ front = front -> next; } if(front->next==NULL){ return head->next; } front = front->next; rem = rem->next; while(front->next!=NULL){ front = front->next; rem = rem->next; back = back->next; } back ->next = rem->next; return head;}
0 0
- 19. Remove Nth Node From End of List leetcode list
- [LeetCode]19.Remove Nth Node From End of List
- LeetCode 19. Remove Nth Node From End of List
- 19. Remove Nth Node From End of List Leetcode Python
- LeetCode --- 19. Remove Nth Node From End of List
- LeetCode 19.Remove Nth Node From End of List
- [Leetcode] 19. Remove Nth Node From End of List
- [leetcode] 19.Remove Nth Node From End of List
- <LeetCode OJ> 19. Remove Nth Node From End of List
- 19. Remove Nth Node From End of List LeetCode
- leetcode 19. Remove Nth Node From End of List
- [LeetCode OJ] 19. Remove Nth Node From End of List
- LeetCode 19. Remove Nth Node From End of List
- Leetcode:19. Remove Nth Node From End of List(JAVA)
- leetcode 19. Remove Nth Node From End of List
- Leetcode 19. Remove Nth Node From End of List
- 【LeetCode】19. Remove Nth Node From End of List
- leetcode 19.Remove Nth Node From End of List
- Geekband STL与泛型编程 第三周笔记 暗影行者
- 4Sum
- PHP md5
- android app 打包问题,jar文件的重复很头疼
- Android SwitchCompat 自定义颜色 及使用
- leetcode 19. Remove Nth Node From End of List
- 推荐算法——基于图的推荐算法PersonalRank算法
- tolua学习资料汇总贴
- win10远程登录提示“您的远程桌面会话已结束。另一用户已连接到此远程计算机,因此您的连接已丢失……”
- 51单片机验证牛顿第二定律
- 面向对象程序设计之五大原则(SOLID)
- matrix矩阵变换
- 大数据技术词汇表
- 几个有意思的小程序