 New update is available. Click here to update.

# Find rank

Last Updated: 27 Nov, 2020
Difficulty: Easy

## PROBLEM STATEMENT

#### The rank of a matrix is defined as:

``````(a) The maximum number of linearly independent column vectors in the matrix or
(b) The maximum number of linearly independent row vectors in the matrix. Both definitions are equivalent.
``````

#### Linear independence is defined as:

``````In the theory of vector spaces, a set of vectors is said to be linearly dependent if there is a nontrivial linear combination of the vectors that equals the zero vector. If no such linear combination exists, then the vectors are said to be linearly independent.
``````
##### Input format:
``````The first line contains a single integer ‘T’ denoting the number of test cases.

The first line of every test case contains two space-separated integers, ‘N’ and ‘M’, denoting the number of rows and the number of columns respectively.

Then each of the next ‘N’ rows contains ‘M’ elements.
``````
##### Output format:
``````For each test case, return the rank of the matrix.
``````
##### Note:
``````You do not need to print anything. It has already been taken care of. Just implement the given function.
``````
##### Constraints:
``````1 <= T <= 10
1 <= N , M <= 500
-10^4 <= Arr[i][j] <= 10^4

Where ‘ARR[i][j]’ denotes the matrix element at the jth column in the ith row of ‘ARR’

Time Limit: 1 sec
``````