New game of Oz
Practice
3.7 (393 votes)
Ad Hoc
Approved
Easy
Open
Sorting
Problem
45% Success 7144 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Today Oz is playing a new game. He has an array arr[] of N distinct integers . In each turn he is will follow two actions -
1) He select a random number from arr[]. Say value of this element is X.
2) He will remove X from arr[]. if X-1 is present in arr[] then he will remove it. if X+1 is present in arr[] then he will remove it.
Oz will make turns until arr[] becomes empty. Oz loves this game so he wants to make maximum number of possible turns. Help Oz to make maximum number of possible turns.

Input :
The first line contains the number of test cases - T . Each test case consist of two lines. First line will contain a integer N - number of elements in arr[]. Second line will contain N space separated integers.

Output :
For each test case output maximum number of possible turns that Oz can make.

Constraints :
1 ≤ T ≤ 100
1 ≤ N ≤ 100
1 ≤ each element of arr[] ≤ 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:
ArraysEasyMath
Points:20
8 votes
Tags:
ApprovedEasyImplementationapproved
Points:20
17 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation