[LeetCode]206. Reverse Linked List
Posted 张乐乐章
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode]206. Reverse Linked List相关的知识,希望对你有一定的参考价值。
Reverse a singly linked list.
Subscribe to see which companies asked this question.
1 public ListNode reverseList(ListNode head) { 2 if(head==null) return null; 3 if(head.next==null) return head; 4 ListNode pre = head; 5 ListNode cur = head.next; 6 pre.next = null; 7 ListNode next; 8 while(cur != null){ 9 next = cur.next; 10 cur.next = pre; 11 pre = cur; 12 cur = next; 13 } 14 return pre; 15 }
以上是关于[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