We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ca283e3 commit 1749c18Copy full SHA for 1749c18
Linked List/Singly Linked List/ReverseLL.java
@@ -0,0 +1,30 @@
1
+/*
2
+public class Main {
3
+
4
+ static class Node {
5
+ int data;
6
+ Node next;
7
8
+ public Node(int data) {
9
+ this.data = data;
10
+ this.next = null;
11
+ }
12
+ }*/
13
+public static Node reverseList(Node head) {
14
+ Node prev = null;
15
+ Node current = head;
16
+ Node next = null;
17
18
+ while (current != null) {
19
+ next = current.next;
20
21
+ current.next = prev;
22
23
+ prev = current;
24
+ current = next;
25
26
27
+ return prev;
28
29
30
0 commit comments