Submission Detail

2094 / 2094 test cases passed.
Status:

Accepted

Runtime: 3 ms
Memory Usage: 44.9 MB
Submitted: 2 weeks, 1 day ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0
5
10
15
20
25
30
35
40
10
20
30
40
50
60
java
You are here!
Your runtime beats 46.44 % of java submissions.
Runtime (ms)
Distribution (%)

0
5
10
15
20
25
30
35
40
20
40
60
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

42000
42500
43000
43500
44000
44500
45000
2.5
5.0
7.5
10.0
12.5
java
You are here!
Your memory usage beats 16.46 % of java submissions.
Memory (KB)
Distribution (%)

42000
42500
43000
43500
44000
44500
45000
5
10
Zoom area by dragging across this chart

Invite friends to challenge Median of Two Sorted Arrays


Submitted Code: 2 weeks, 1 day 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
class Solution {
public double findMedianSortedArrays(int[] nums1, int[] nums2) {
int c1 = 0;
int c2 = 0;
int m = 0;
int merged_size = nums1.length+nums2.length;
int[] medians = new int[merged_size];
if (nums1.length == 0)
for (int i = 0; i < nums2.length; i++)
medians[i] = nums2[i];
if (nums2.length == 0)
for (int i = 0; i < nums1.length; i++)
medians[i] = nums1[i];
while (c1 < nums1.length && c2 < nums2.length) {
if (nums1[c1] < nums2[c2]) {
medians[m++] = nums1[c1];
c1++;
} else {
medians[m++] = nums2[c2];
c2++;
}
}
while (c1 < nums1.length)
medians[m++] = nums1[c1++];
while (c2 < nums2.length)
medians[m++] = nums2[c2++];
double median = 0;
if (medians.length % 2 == 0) {
median =(double)(medians[(medians.length/2)-1] + medians[medians.length/2])/2;
} else {
median = medians[medians.length/2];
}
return median;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX