Remove Nth Node from End of List
来源:互联网 发布:ai软件作品 编辑:程序博客网 时间:2024/04/30 15:21
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public class Solution { public ListNode removeNthFromEnd(ListNode head, int n) {// Start typing your Java solution below// DO NOT write main() functionif(head == null)return null;int i = 0;ListNode tail = head;ListNode node = head;while(i++ < n){tail = tail.next;}if(tail == null)return head.next;while(tail.next != null){tail = tail.next;node = node.next;}node.next = node.next.next;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
- 02-使用navicat 连接oracle数据库
- 之前IK动画算法的补充
- struts2读数据库
- [2013-05-15]centos6.3 x86_64配置yum
- 无界面更新上传头像(jsp+iframe版)
- Remove Nth Node from End of List
- 《Cocos2d-x权威指南》11-12章实例代码2.1.3修正
- linux系统新手学习的11点建议
- MATLAB中运用imagesc函数显示图像,怎么出来的图像与原图像比例不一样?
- 求三个数中的最大值
- C++字符数组越界问题的一个案例分析
- 如何读取CSV数据到DataTable中
- shell学习笔记之三——正则表达式
- zoj 1410 Number Sequence