LeetCode 206. Reverse Linked List
2017-04-17 00:29
381 查看
Reverse a singly linked list.
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public ListNode reverseList(ListNode head) { if(head==null || head.next==null) return head; else{ ListNode p=head.next; ListNode q=p.next; ListNode tail=head; tail.next=null; while(q!=null){ p.next=tail; tail=p; p=q; q=q.next; } p.next=tail; return p; } } }
相关文章推荐
- 【leetcode】206.Reverse Linked List
- 【LeetCode】206. Reverse Linked List
- 【leetcode】206. Reverse Linked List My Submissions Question
- LeetCode-206. Reverse Linked List
- LeetCode 206. Reverse Linked List
- LeetCode-206. Reverse Linked List
- LeetCode 206. Reverse Linked List
- [LeetCode] 206. Reverse Linked List
- LeetCode 206. Reverse Linked List
- 【LeetCode】206. Reverse Linked List
- [leetcode]206. Reverse Linked List
- 206. Reverse Linked List leetcode list
- Leetcode-206. Reverse Linked List
- [LeetCode]206. Reverse Linked List&92. Reverse Linked List II
- Leetcode 206. Reverse Linked List
- LeetCode 206. Reverse Linked List
- Leetcode题解 206. Reverse Linked List
- Leetcode 206. Reverse Linked List
- Leetcode206. Reverse Linked List
- [leetcode] 206.Reverse Linked List