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

Commiteb5758c

Browse files
Merge pull requestneetcode-gh#314 from SharmaTushar1/patch-11
Create 83. Remove Duplicates from Sorted List.java
2 parentsd9f4c20 +31aa19e commiteb5758c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//Three pointer approach that we use in in-place reversal of linked list.
2+
3+
classSolution {
4+
publicListNodedeleteDuplicates(ListNodehead) {
5+
ListNodep =null;
6+
ListNodeq =null;
7+
ListNoder =head;
8+
while (r!=null) {
9+
if (q!=null &&q.val ==r.val) {
10+
r =r.next;
11+
q.next =r;
12+
}else {
13+
p =q;
14+
q =r;
15+
r =r.next;
16+
}
17+
}
18+
returnhead;
19+
}
20+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp