Remove Nth Node From End of List
来源:互联网 发布:ios软件安装目录 编辑:程序博客网 时间:2024/04/30 10:16
public ListNode removeNthFromEnd(ListNode head, int n) { // Start typing your Java solution below // DO NOT write main() function ListNode fast = head; for(int i = 1; i <= n; i++) { if(fast == null) return head; fast = fast.next; } if(fast == null) {//delete the head; ListNode tmp = head; head = head.next; tmp.next = null; return head; } ListNode slow = head; while(fast.next != null) { fast = fast.next; slow = slow.next; } ListNode tmp = slow.next; slow.next = slow.next.next; tmp.next = null; return head; }
- 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
- Linux 的启动流程
- int与size_t
- LeetCode - Jump Game
- 千万小心IE的session不能及时更新的问题!
- Linux下缓冲区溢出攻击的原理及对策
- Remove Nth Node From End of List
- HTML5学习
- myeclipse 调试技巧
- 读写随机访问文件
- centos6.4配置ip dns
- flex 和webService 通讯
- C++11 理解 (二十三) 之 通用智能指针
- MyXls导出Excel的各种设置
- [Oracle] Data Guard 系列(5) - 创建逻辑备库