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
int size = arr1.length;
int m = 0;
int ret = 0;
for (int i = 0, j = 0; i < arr1.length && j < arr2.length; ) {// 双指针,两个数组大小比较并移动。
if (arr1[i] <= arr2[j]) {
ret = arr1[i];
i++;
} else if (arr1[i] > arr2[j]) {
ret = arr2[j];
j++;
}
m++;
if (m == size) {
return ret;
}
}
return ret;
}
}