mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-10 00:09:06 +01:00
15 lines
236 B
Java
15 lines
236 B
Java
|
class Solution {
|
||
|
public ListNode reverseList(ListNode head) {
|
||
|
ListNode tail = null;
|
||
|
|
||
|
while (head != null) {
|
||
|
var tmp = head.next;
|
||
|
head.next = tail;
|
||
|
tail = head;
|
||
|
head = tmp;
|
||
|
}
|
||
|
|
||
|
return tail;
|
||
|
}
|
||
|
}
|