Group of countries
Practice
0 (0 votes)
Open
Open
Open
Implementation
Recursion
Basic programming
Arrays
Easy
Mathematics
Basics of implementation
Problem
95% Success 22 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
People in a group are sitting in a row that is numbered from \(1\) to \(N\). Every person has been asked the same question that is as follows:
How many people of your country are there in the group?
The answers that are provided may be incorrect. It is known that people of same countries always sit together. If all the given answers are correct, then determine the number of distinct countries that exist. Otherwise, print 'Invalid Data'.
Input format
- First line: An integer \(T\) that denotes the number of test cases
- For each test case:
- First line: An integer \(N\) that denotes the total number of people who are available in the group
- Second line: \(N\) space-separated integers where \(A_i\) denotes the answer that is given by the \(i^{th}\) person
Output format
For each test case, print a single line containing a single integer that denotes the distinct countries or 'Invalid Data'.
Constraints
\(1 \le T \le 1000\)
\(1 \le N \le 100 \)
\(1 \le A_i \le 1000\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
HiringHiringHiringBasic ProgrammingImplementationEasyBasics of Implementation
Points:30
Tags:
MediumSortingAlgorithmsAdvanced sortingArraysSetAdvanced Sorting
3.Balls
Points:20
76 votes
Tags:
Easy
Editorial