剑指Offer_15_反转链表
来源:互联网 发布:淘宝韩版女装店铺装修 编辑:程序博客网 时间:2024/05/17 00:57
题目描述
输入一个链表,反转链表后,输出链表的所有元素。
解题思路
从头结点开始遍历,插入新的链表,每次在链表头插入结点。
实现
/*结点定义*/public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; }}/*实现*/public class Solution { public ListNode ReverseList(ListNode head) { if (head == null) return head; ListNode p = head, next; head = null; while (p != null){ next = p.next; p.next = head; head = p; p = next; } return head; }}
0 0
- 剑指Offer_15_反转链表
- 剑指:反转链表
- 剑指offer:反转链表
- 剑指offer16--反转链表
- 剑指offer--反转链表
- 剑指offer--反转链表
- 剑指off-反转链表
- 剑指Offer-反转链表
- 《剑指offer》反转链表
- 剑指 offer:反转链表
- 剑指offer-反转链表
- 剑指offer 反转链表
- 剑指offer-反转链表
- 剑指offer:反转链表
- [剑指offer]反转链表
- 《剑指offer》-反转链表
- 剑指Offer:反转链表
- 剑指offer----反转链表
- Android API Guides (译)导读
- 软件工程概述
- 软件开发过程二 编码
- 省市二级菜单
- Exception in thread "main" java.lang.NoClassDefFoundError: Server (wrong name: com/it/www/Server)
- 剑指Offer_15_反转链表
- 随机化快排(1)
- 软件开发过程三 测试和维护
- ThinkPHP5.0 index.php随便放那个目录以及相关的修改
- iOS_pop动画
- 软件开发过程四 软件质量管理
- strstr中的while和do-while模型
- 工作中遇到的一些常用linux命令
- 软件开发过程五 用户界设计