Submission Detail

231 / 231 test cases passed.
Status:

Accepted

Runtime: 374 ms
Memory Usage: 42.2 MB
Submitted: 3 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
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

40800
41000
41200
41400
41600
41800
42000
42200
42400
42600
2
4
6
8
java
You are here!
Your memory usage beats 36.85 % of java submissions.
Memory (KB)
Distribution (%)

40800
41000
41200
41400
41600
41800
42000
42200
42400
42600
5
Zoom area by dragging across this chart

Invite friends to challenge Rotate List


Submitted Code: 3 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
/**
* 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 rotateRight(ListNode head, int k) {
if (head == null || head.next == null)
return head;
ListNode i = head;
int size = 0;
// get list size
while (i != null) {
size++;
i = i.next;
}
if (k == size)
return head;
// get true shift value
while (k > size)
k -= size;
int count = 0;
ListNode h = head;
while (count < k) {
while (h.next.next != null)
h = h.next;
h.next.next = head;
head = h.next;
h.next = null;
h = head;
count++;
}
return head;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX