LEETCODE 206
来源:互联网 发布:手机txt制作软件 编辑:程序博客网 时间:2024/04/26 13:00
Reverse a singly linked list.
click to show more hints.
Hint:
A linked list can be reversed either iteratively or recursively. Could you implement both?
Subscribe to see which companies asked this question
旋转指针,比较简单的题。
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* reverseList(ListNode* head) { ListNode* pre = NULL; ListNode* nxt = head; while(nxt) { ListNode* temp = nxt->next; nxt->next = pre; pre = nxt; nxt = temp; } return pre; }};
0 0
- Leetcode 206
- LEETCODE 206
- Leetcode 206
- leetcode 206
- LeetCode #206
- leetcode 237和leetcode 206
- <LeetCode><Easy>206 ReverseLinkedList
- LeetCode 206 单链表逆置
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode
- leetcode:
- leetcode:
- LeetCode
- leetcode
- LEETCODE
- MyBatis Mapper接口实现原理
- 用numpy打开图像和保存图像----找了很久的资料
- php 封装Memcache 队列缓存类
- 集合的子集
- Spring3.1新属性管理API:PropertySource、Environment、Profile
- LEETCODE 206
- 类和对象&重载
- 推荐组装机使用小机箱
- MVC框架简谈与在Android中的应用
- Collections.unmodifiableList
- Quartz源码分析之HelloWorld示例
- 小学生算术能力测试系统
- Tomcat设置默认启动项目及Java Web工程设置默认启动页面
- C++判断一个数是否为素数