import java.util.*;
public class Solution {
/**
* find median in two sorted array
* @param arr1 int整型一维数组 the array1
* @param arr2 int整型一维数组 the array2
* @return int整型
*/
public int findMedianinTwoSortedAray (int[] arr1, int[] arr2) {
// write code here
ArrayList list=new ArrayList();//此方法不是二分,是用list模拟人,找中位数,运行速度不是很快,但思路简单
for(int i:arr1){
list.add(i);
}
for(int i:arr2){
list.add(i);
}
Collections.sort(list);
return (int)list.get((list.size())/2-1);
}
} 
京公网安备 11010502036488号