Monk and the Collision
Practice
3.3 (154 votes)
Easy
Open
Hash function
Hash table
Problem
92% Success 9405 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

As the Monk is also taking part in the CodeMonk Series, this week he learned about hashing. Now he wants to practice some problems. So he came up with a simple problem. Firstly, he made a hash function F such that:

F(x) = x % 10

Now using this function he wants to hash N integers and count the number of collisions that will occur while hashing the integers.

Input:
The first line 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 integers to hash.
The next line contains N space separated integers, denoting the integer X to hash.

Output:
For each test case, print the number of collisions that will occur while hashing the integers.

Constraints:
1 <= T <= 10
1 <= N <= 100
0 <= X <= 105

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
12 votes
Tags:
Hash tableHashMapBasic ProgrammingEasyOpenApproved
Points:20
8 votes
Tags:
Hash functionImplementationBinary search treeData StructuresHash tableOpenApprovedEasy
Points:20
4 votes
Tags:
Hash tableHashMapBasic ProgrammingEasyOpenApproved