diff --git a/java/reverse-linked-list.java b/java/reverse-linked-list.java new file mode 100644 index 0000000..131ef13 --- /dev/null +++ b/java/reverse-linked-list.java @@ -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; + } +}