Associated Course(s):
Fundamentals of Programming with C

Given an unsorted array **Arr[]** of **N** integers and a **Key** which is present in this array. You need to write a program to find the **start index**( index where the element is first found from left in the array ) and **end index**( index where the element is first found from right in the array ).

**Input:**

Fisrt line of input contains an integer **T** which denotes the number of test cases. First line of each test case contains a single integer N which denotes the number of elements in the array. Second line of each test case contains N space separated integers. Third line of each test case contains the key to be searched.

**Output:**

For each test case print two space separated integeres, first is the start index and second is the end index. If the key doesnot exist in the array then print -1 in this case.

**Constraints:**

1<=T<=100

1<=N<=10^{5}

1<=Arr[i]<=10^{4}

**Example:
Input:**

2

6

1 2 3 4 5 5

5

6

6 5 4 3 1 2

4

4 5

2 2

Author: harsh.agarwal0

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.

_Shubham_Jain_06 | 404 |

maggiiiii | 315 |

Savage_19 | 310 |

ritikdagar0203 | 241 |

thanuvinu94 | 233 |

Bishnu Dev Panda | 810 |

_Shubham_Jain_06 | 715 |

okayboss | 652 |

maggiiiii | 598 |

Savage_19 | 576 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.