* find median in two sorted array
 * @param arr1 int整型一维数组 the array1
 * @param arr2 int整型一维数组 the array2
 * @return int整型
 */
function findMedianinTwoSortedAray( arr1 ,  arr2 ) {
    // write code here
    let index = (arr1.length + arr2.length)/2;
    let p = 0,p1 = 0,p2 = 0,temp;
    while(p1 < arr1.length || p2 < arr2.length){
        if(arr1[p1] <= arr2[p2]){
            temp = arr1[p1];
            p1++;
        }else{
            temp = arr2[p2];
            p2++;
        }
        p++;
        if(p == index){
            return temp;
        }
    }
    if(p1 > p2){
        return arr1[arr1.length - 1];
    }else{
        return arr2[arr2.length - 1];
    }
}
module.exports = {
    findMedianinTwoSortedAray : findMedianinTwoSortedAray
};

alt