Submission Detail

38 / 38 test cases passed.
Status:

Accepted

Runtime: 1 ms
Memory Usage: 55.2 MB
Submitted: 4 days, 21 hours ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0
2
4
6
8
10
12
14
16
10
20
30
40
50
java
You are here!
Your runtime beats 53.40 % of java submissions.
Runtime (ms)
Distribution (%)

0
2
4
6
8
10
12
14
16
20
40
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

50000
51000
52000
53000
54000
55000
56000
57000
58000
59000
2
4
6
8
java
You are here!
Your memory usage beats 94.70 % of java submissions.
Memory (KB)
Distribution (%)

50000
51000
52000
53000
54000
55000
56000
57000
58000
59000
2.5
5.0
7.5
Zoom area by dragging across this chart

Invite friends to challenge Rotate Array


Submitted Code: 4 days, 21 hours 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
class Solution {
public void rotate(int[] nums, int k) {
if (k > nums.length)
k = k % nums.length;
int start = nums.length - k;
if (nums.length == 1)
return;
int[] rotated = new int[nums.length];
int ind = 0;
for (int i = start; i < nums.length; i++)
rotated[ind++] = nums[i];
for (int i = 0; i < start; i++)
rotated[ind++] = nums[i];
for (int i = 0; i < nums.length; i++)
nums[i] = rotated[i];
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX