Driver code
public static void main ( String [ ] args ) { int arr1 [ ] = { 2 , 3 , 6 , 7 , 9 } ; int arr2 [ ] = { 1 , 4 , 8 , 10 } ; int m = arr1 . length ; int n = arr2 . length ; int k = 5 ; int ans = kth ( arr1 , m , arr2 , n , k ) ; if ( ans == - 1 ) System . out . println ( " Invalid ▁ query " ) ; else System . out . println ( ans ) ; } }