Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e0cdb7

Browse files
Create 206. Reverse Linked List.java
1 parent5be3c73 commit4e0cdb7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎java/206. Reverse Linked List.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
classSolution {
3+
publicListNodereverseList(ListNodehead) {
4+
ListNodep =null;
5+
ListNodeq =null;
6+
ListNoder =head;
7+
while (r!=null) {
8+
p =q;
9+
q =r;
10+
r =r.next;
11+
q.next =p;
12+
}
13+
returnq;
14+
}
15+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp