LeetCode-19-Remove-Nth-Node-From-End-of-List 链表水题
来源:互联网 发布:淘宝欢乐逛 编辑:程序博客网 时间:2024/06/05 09:38
# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ h=head cnt=1 while h.next!=None: cnt+=1 h=h.next p=cnt-n+1 if p==1:return head.next h=head cnt2=1 while h.next!=None: if cnt2==p-1: h.next=h.next.next return head cnt2+=1 h=h.next
阅读全文
1 0
- LeetCode-19-Remove-Nth-Node-From-End-of-List 链表水题
- [Leetcode]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, Easy] 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 Solutions
- 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 | #19 Remove Nth Node From End of List
- leetcode.19----------Remove Nth Node From End of List
- [Leetcode 19, Easy] 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 19 Remove Nth Node From End of List
- An internal error occurred during: "Launching House on Tomcat 7.x". java.lang.NullPointerException
- 资料位置保存
- Linux Shell脚本攻略2:命令之乐(1)
- 全面升级Android面试之Asynctask面试题集
- 送外卖 拓扑排序+状压DP+最短路
- LeetCode-19-Remove-Nth-Node-From-End-of-List 链表水题
- PAT乙级1070. 结绳(25)
- 《C#图解教程》第1章 C#和.NET框架 读书笔记
- InstallShield 软件打包完整教程
- 【Computer vision】摄像机矩阵的分解
- 51nod 1020 逆序排列【DP】
- STL中的队栈以及优先队列
- LeetCode 160. Intersection of Two Linked Lists
- 元素定位