标签:
逆转单链表。/**
* Definition for singly-linked list.
* public class ListNode {
* public int val;
* public ListNode next;
* public ListNode(int x) { val = x; }
* }
*/
public class Solution {
public ListNode ReverseList(ListNode head) {
ListNode h = null;
while(head != null){
var n = new ListNode(head.val);
n.next = h;
h = n;
head = head.next;
}
return h;
}
}版权声明:本文为博主原创文章,未经博主允许不得转载。
LeetCode -- Reverse Linked List
标签:
原文地址:http://blog.csdn.net/lan_liang/article/details/48576059