Submission Detail

166 / 166 test cases passed.
Status:

Accepted

Runtime: 0 ms
Memory Usage: 42.7 MB
Submitted: 0 minutes ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0
1
2
3
4
5
6
7
8
9
10
11
12
13
20
40
60
80
100
java
You are here!
Your runtime beats 100.00 % of java submissions.
Runtime (ms)
Distribution (%)

0
1
2
3
4
5
6
7
8
9
10
11
12
13
50
100
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

41000
41250
41500
41750
42000
42250
42500
42750
43000
43250
43500
2
4
6
8
java
You are here!
Your memory usage beats 42.05 % of java submissions.
Memory (KB)
Distribution (%)

41000
41250
41500
41750
42000
42250
42500
42750
43000
43250
43500
5
Zoom area by dragging across this chart

Invite friends to challenge Remove Duplicates from Sorted List II


Submitted Code: 0 minutes ago

Language: java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode deleteDuplicates(ListNode head) {
if (head == null)
return null;
if (head.next == null)
return head;
// starting duplicates
for(;;) {
if (head != null && head.next != null
&& head.val == head.next.val) {
while (head.next != null && head.val == head.next.val)
head = head.next;
head = head.next;
} else {
break;
}
}
if (head == null)
return null;
ListNode prev = head;
ListNode h = head;
// interior duplicates
while (head != null && head.next != null) {
if (head.val == head.next.val) {
ListNode dup = head;
while (dup.next != null && dup.val == dup.next.val)
dup = dup.next;
dup = dup.next;
prev.next = dup;
head = prev.next;
} else {
prev = head;
head = head.next;
}
}
return h;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX