

Let the size of fishes present in the river from left to right be{ 4, 2, 3, 1, 5 }.
1. As fish 4 is faster and bigger than fish 2, so fish 4 will eat fish 2.
Remaining fishes: { 4, 3, 1, 5 }
2. As fish 3 is faster and bigger than fish 1, so fish 3 will eat fish 1.
Remaining fishes: { 4, 3, 5 }
3. As fish 4 is faster and bigger than fish 3, so fish 4 will eat fish 3.
Remaining fishes: { 4, 5 }
Now fish 5 cannot eat fish 4, as fish 5 is faster than fish 4 and they swim from left to right. Thus, fish 4 will never reach fish 5.
Finally, we are left with only 2 fishes.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains an integer ‘N’ denoting the number of fishes.
The second line of each test case contains 'N' single space-separated integers representing the size of the fishes.
For each test case, return the number of fishes that survives till last.
You don't need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^4
1 <= FISHES[i] <= 10^9
Where 'FISHS[i]' denotes the size of the ith fish in the river.
Time limit: 1 sec
The first approach would be to simply check if a fish will be alive at the end or not. We can find this just by checking if a fish has any bigger fish behind it or not.
The steps are as follows:
All we need to find if a fish is alive or not by checking if it is bigger than the largest fish behind it or not.
The steps are as follows :