import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param arr1 int整型一维数组 
     * @param arr2 int整型一维数组 
     * @param target int整型 
     * @return int整型
     */
    public int findKthNum (int[] arr1, int[] arr2, int target) {
        // write code here
        int p1 = 0;
        int p2 = 0;
        int account = 0;
        int res = 0;
        while (p1 < arr1.length && p2 < arr2.length) { // 越界
            if (arr1[p1] <= arr2[p2]) {
                res = arr1[p1];
                p1++;
            }
            else {
                res = arr2[p2];
                p2++;
            }
            account++;
            if (account == target) {
                return res;
            }
        }
        while (account < target && p1 < arr1.length) {
            res = arr1[p1];
            account++;
            p1++;
        }
        while (account < target && p2 < arr2.length) {
            res = arr2[p2];
            account++;
            p2++;
        }
        return res;
    }
}