class Solution {
public ListNode reverseList(ListNode head) {
ListNode before = null;
ListNode next = null;
ListNode now = head;
while(now != null) {
next = now.next;
now.next = before;
before = now;
now = next;
}
return before;
}
}
Leetcode_206_反转链表_数据结构
最新推荐文章于 2023-04-11 21:28:31 发布