public static double findMedianSortedArrays(int[] A, int[] B) {
// write code here
List<Double> list = new ArrayList<>();
for (int i = 0; i < A.length + B.length; i++) {
if (i < A.length) {
list.add((double) A[i]);
} else {
list.add((double) B[(A.length + B.length) - i - 1]);
}
}
Collections.sort(list);
if ((A.length + B.length) % 2 == 0) {
return (list.get((A.length + B.length) / 2) + list.get((A.length + B.length) / 2 - 1)) / 2;
} else {
return (list.get((A.length + B.length) / 2));
}
}