Countries Grouping
Practice
3.4 (27 votes)
Arrays
Easy
Implementation
Math
Recursion
Problem
87% Success 6788 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

People in the group, are sitting in a row numbered from 1 to N. Every person have been asked with a same question as

How many people of your country are there in the group?

The answers provided may be incorrect. It is known that people of same countries always sit together.

If all the given answers are correct, determine the number of distinct countries present otherwise print "Invalid Data".

Input

First line contains one integer, which denotes the number of test cases

Each test case consists of 2 lines:

The first line contains one integer N, which denotes the total number of people there in the group.

The second line contains N space-separated integers say \(A_i\) , which denotes the answer given by the \(i^{th}\) person.

Output

For each test case output a single line containing a single integer denoting the distinct countries or "Invalid Data".

Constraints:

\(1 \le T \le 1000\)
\(1 \le N \le 100 \)
\(1 \le A_i \le 1000\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
58 votes
Tags:
Ad-HocAlgorithmsApprovedEasyImplementationOpen
Points:20
22 votes
Tags:
Ad-HocApprovedEasyImplementationMathOpen
Points:20
836 votes
Tags:
Ad-HocSimulationEasyMathematicsOpenApprovedMathamatics