Timer is Running

Given a sorted array of numbers, value K and an index X in array, find the K closest numbers in position to X in array.

Example: Let array be 11 23 24 75 89, X be 24 and K be 2. Now we have to find K numbers closest to X that is 24. In this example, 23 and 75 are the closest 2 numbers to 24.

**Note: **K should be even and in cases with less than k/2 elements on left side or right side, we need to print other side elements. Like 2 4 5 6 7, X be 6 and K be 4 then answer is 2 4 5 7

**Input:**

The first line of input contains an integer T denoting the number of test cases.

The first line of each test case is N,N is the size of array.

The second line of each test case contains N input C[i].

The third line of each test case contains K and X.

**Output:**

Print K closest number in position to X in array.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ N ≤ 100

1 ≤ C[i] ≤ 1000

**Example:**

Input

1

5

11 23 24 75 89

2 24

Output

23 75

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

sandeep28august | 642 |

sudhanmadhu7981 | 631 |

RudraKaniya | 624 |

ishaanprajapati808 | 620 |

saxenadivyanshi004 | 572 |

sandeep28august | 642 |

sudhanmadhu7981 | 631 |

RudraKaniya | 629 |

ishaanprajapati808 | 620 |

saxenadivyanshi004 | 572 |

blackshadows | 5362 |

Ibrahim Nash | 5244 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4736 |

Login to report an issue on this page.