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 mid = (arr1.length + arr2.length) / 2;
        int ret = 0;
        int a1 = 0;
        int a2 = 0;
        while (a1 < arr1.length && a2 < arr2.length) {
            if (arr1[a1] < arr2[a2]) {
                ret = arr1[a1++];
                mid--;
            }else {
                ret = arr2[a2++];
                mid--;
            }
            if (mid == 0) {
                return ret;
            }
        }
        
        return ret;
    }
}