We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed259ed commit 08066dfCopy full SHA for 08066df
java/206. Reverse Linked List.java
@@ -0,0 +1,15 @@
1
+//Use three pointers and so you can change the next of the mid to the first one without losing the track of the original left.
2
+class Solution {
3
+ public ListNode reverseList(ListNode head) {
4
+ ListNode p = null;
5
+ ListNode q = null;
6
+ ListNode r = head;
7
+ while (r!=null) {
8
+ p = q;
9
+ q = r;
10
+ r = r.next;
11
+ q.next = p;
12
+ }
13
+ return q;
14
15
+}
0 commit comments