New update is available. Click here to update.

Last Updated: 10 Jul, 2021

Difficulty: Hard

```
The first line of input contains a single integer T, denoting the number of test cases.
The first line of each test case contains ‘N’, denoting the number of cities, ‘M’ denoting the number of trains, and ‘K’ denoting the size of the connected network of cities.
The second line of each test case contains 'N' space-separated integers denoting the value associated with the i-th city.
The next 'M' lines of each test case contains ‘M’ pairs (u, v), denoting a train available from city u to city v.
```

```
The first and only line of each test case contains the maximum threshold value X, if the maximum threshold value is infinite the return 10 ^ 9. If there is no connected network of cities of size at least K, then return -1.
```

```
You are not required to print the expected output; it has already been taken care of. Just implement the function.
```

```
1 <= T <= 5
1 <= k <= N <= 10^5
1 <= M <= 10^5
1 <= value of nodes <= 10 ^ 9
Time limit: 2 second
```

SIMILAR PROBLEMS

Find minimum

Posted: 8 Nov, 2022

Difficulty: Hard

Search In A Sorted 2D Matrix

Posted: 23 Nov, 2022

Difficulty: Moderate

Ninja And The Strictly Increasing Array

Posted: 27 Nov, 2022

Difficulty: Moderate

Maximize

Posted: 9 Dec, 2022

Difficulty: Easy

Fake Coin Problem

Posted: 24 Dec, 2022

Difficulty: Easy

Popular Interview Problems: