Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 786 |

@arpitsatnalika | 777 |

@tujhekya | 602 |

@prakharxyz | 601 |

@code_it_ | 591 |

@iamronak | 505 |

@imnm | 500 |

@pradeepkumarjad | 488 |

@satyam0460 | 481 |

@nitesha125 | 468 |

@Rahul Jadhav 1 | 466 |

Complete Leaderboard |

Given two sorted arrays **A** and **B** of size **M** and **N** respectively and an element k. The task is to find the element that would be at the k’th position of the final sorted array.

**Input:**

First line consists of test cases T. First line of every test case consists of 3 integers N, M and K, denoting M number of elements in A, N number of elements in B and k^{th} position element. Second and Third line of every test case consists of elements of A and B respectively.

**Output:**

Print the element at the Kth position.

**Constraints:**

1 <= T <= 200

1 <= N, M <= 10^{6}

1 <= A_{i}, B_{i} <= 10^{6}

1 <= K <= N+M

**Example:
Input:**

1

5 4 5

2 3 6 7 9

1 4 8 10

**Output:**

6

**Explanation:
Testcase 1:** Element at 5th position after merging both arrays will be 6.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
K-th element of two sorted Arrays

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.