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
3

# Max Town Order

Difficulty: EASY
Contributed By
Avg. time to solve
15 min
Success Rate
85%

Problem Statement

#### Suppose there is a city of N towns and M bidirectional roads. The town order of two different towns is defined as the total number of directly connected roads to either town. If a road is directly connected to both towns, it is only counted once. The maximal town order of the city is the maximum town order of all pairs of different towns. Your task in this problem is to print the maximal town order of the city.

##### Input Format :
``````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.
``````
##### Output Format :
``````For each test print an integer denoting the maximal town order of the city.
``````
##### Note :
``````Don't print anything it has already been taken care of. Just implement the given function
``````
##### Constraints :
``````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
``````
##### Sample Input 1 :
``````2
5 6
0 1
0 3
1 2
1 3
2 3
2 4
4 0
``````
##### Sample Output 1 :
``````5
0
``````
##### Explanation For Sample Input 1 :
``````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:

``````
##### Sample Input 2 :
``````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
``````
##### Sample Output 2 :
``````4
5
``````
Console