"206-reverse Linked list (invert a single linked list)""leetcode-Interview algorithm classic-java Implementation" "All topics Directory Index"code Download "Https://github.com/Wang-Jun-Chao"Original Question
Reverse a singly linked list.
Main Topic
Reverses a single linked list.
Thinking of solving problems
Use the head interpolation method.
Code Implementation
Node class
publicclass ListNode { int val; ListNode next; ListNode(int x) { val = x; }}
Algorithm implementation class
publicclass Solution { publicreverseList(ListNode head) { // 头结点 new ListNode(0); ListNode nextNode; whilenull) { nextNode = head.next; head.next = root.next; root.next = head; head = nextNode; } return root.next; }}
Evaluation Results
Click on the picture, the mouse does not release, drag a position, release after the new window to view the full picture.
Special InstructionsWelcome reprint, Reprint please indicate the source "http://blog.csdn.net/derrantcm/article/details/48021429"
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Leetcode-Interview algorithm classic-java Implementation" "206-reverse Linked List (invert a single linked list)"