1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-16 16:36:56 +02:00

java: add «206. Reverse Linked List»

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2024-03-21 10:42:25 +01:00
parent 84ba9d343b
commit 7dc90ebe06
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,14 @@
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;
}
}