Kth Smallest Element and median of Two Sorted Arrays

Given two sorted arrays find the element which would be kth in their merged and sorted combination.

For example, A=[1, 1, 2, 3, 10, 15] and B=[-1, 2, 3, 4, 6, 7] then k=8th smallest element would be 4 as it appears in 8th position of the merged sorted array=[-1, 1, 1, 2, 2, 3, 3, 4, 6, 7, 10, 15].