Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
reverse Linked List
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class ListNode { int val; ListNode next; ListNode(int x) { val = x; } } class Rextester { public static void main(String args[]) { System.out.println("Hello, World!"); } public ListNode reverseList(ListNode head) { ListNode curr = head; ListNode prev = null; while(curr!=null){ ListNode tmp = curr.next; curr.next = prev; prev = curr; curr = tmp; } return prev; } }
run
|
edit
|
history
|
help
0
Granite Java
Java Constructors
Cyclically rotate array
OBF-7
quickSort_LinkedList
vampires number Eckel B. Thinking in Java
Frequency
swastik
Sort arraylist bubble sort
Largest prime factor