All Problems

Problem title

Difficulty

Avg time to solve

Program for Priority CPU Scheduling | Set 1

Easy

15 mins

Online Majority Element In Subarray

Moderate

15 mins

Create Sorted Array through Instructions

Moderate

20 mins

Lexicographically smallest equivalent string

Moderate

25 mins

Block Heights

Easy

20 mins

Identical sentences

Hard

40 mins

Find All Paths In DAG

Moderate

30 mins

Max Town Order

Easy

15 mins

Second Minimum Node In A Binary Tree

Easy

20 mins

Find The Sum Of The Left Leaves

Moderate

25 mins

Problem

Submissions

3

Avg. time to solve

15 min

Success Rate

85%

Problem Statement

```
The first line of the input contains ‘T’ denoting the number of test cases.
The first line of each test case contains ‘N’ and ‘M’ denoting the number of towns and number of roads.
Each of the next M lines contains two space-separated integers u and v, denoting town u and town v are connected by a road.
```

```
For each test print an integer denoting the maximal town order of the city.
```

```
Don't print anything it has already been taken care of. Just implement the given function
```

```
1 <= T <= 3
2 <= N <= 100
0 <= M <= N*(N-1)/2
0 <= u[i], v[i] <= N-1
Where u[i], v[i] are towns to be connected by a road.
Time Limit: 1 second
```

```
2
5 6
0 1
0 3
1 2
1 3
2 3
2 4
4 0
```

```
5
0
```

```
In the first tet case:
```

```
There are 5 roads connected to towns 1 and town 2, [ [0, 1], [1, 3], [1, 2], [2, 3] , [2, 4] ].
In the second test case:
No road ( edge ) exists thus answer is 0
```

```
2
5 5
3 2
2 1
4 0
0 1
3 1
7 6
2 6
1 5
4 0
1 2
6 5
0 2
```

```
4
5
```

Java (SE 1.8)

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Theme

Solution submission not allowed

Save Code

Reset Code