Submission Detail

168 / 168 test cases passed.
Status:

Accepted

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

Accepted Solutions Runtime Distribution

0.0
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
75
80
85
90
95
100
105
110
java
Runtime (ms)
Distribution (%)

0
1
2
3
4
5
6
7
8
9
10
80
90
100
110
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

40000
40250
40500
40750
41000
41250
41500
41750
42000
42250
2
4
6
8
java
You are here!
Your memory usage beats 55.75 % of java submissions.
Memory (KB)
Distribution (%)

40000
40250
40500
40750
41000
41250
41500
41750
42000
42250
2.5
5.0
7.5
Zoom area by dragging across this chart

Invite friends to challenge Partition List


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 partition(ListNode head, int x) {
if (head == null || head.next == null)
return head;
ListNode lt = new ListNode();
lt = null;
ListNode gt = new ListNode();
gt = null;
ListNode lt_h = lt;
ListNode gt_h = gt;
while (head != null) {
ListNode n = new ListNode(head.val);
if (head.val < x) {
if (lt == null) {
lt = n;
lt_h = lt;
} else {
lt.next = n;
lt = lt.next;
}
}
if (head.val >= x) {
if (gt == null) {
gt = n;
gt_h = gt;
} else {
gt.next = n;
gt = gt.next;
}
}
head = head.next;
}
if (lt_h == null)
return gt_h;
lt.next = gt_h;
return lt_h;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX