Remove Nth Node From End of List
来源:互联网 发布:0.14.1死亡不掉落js 编辑:程序博客网 时间:2024/06/06 05:34
public class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { if (head == null || n==0) return null; ListNode listNode = new ListNode(0); listNode.next = head; ListNode p = listNode; ListNode q = listNode; for (int i=0; i<n; i++){ if (p.next != null) p = p.next; else return head; } while (p.next!=null){ p = p.next; q = q.next; } ListNode tmp = q; q.next = q.next.next; return listNode.next; }}
0 0
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node from End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- IOS开发之自动布局相关问题
- 一道自动机的小题
- STL算法---reverse系列
- ListView显示数据库的数据-采用自定义布局-向上滑动可以加载更多数据
- JAVA基础---基础常识
- Remove Nth Node From End of List
- linux shell教程(四)
- 第一次课 计算机软件基础
- PC和移动的轮播图片开发
- C++中的Aggregate
- UVA 10806 — Dijkstra, Dijkstra. 费用流
- Struts异常处理
- 数据库 访问性能优化
- CSS知识点小总结