Hamming Distance
InterviewTime limit1sMemory limit256 MB
Read two n-dimensional integer vectors and count the positions where their entries differ.
- Level
Easy1 of 10
- Topics
- Implementation, Array
- Solved
- No attempts yet
Problem
The Hamming distance between two -dimensional vectors and is the number of positions at which the corresponding entries differ.
For example, the Hamming distance between and is . The two vectors differ only at the second position and the third position.
Write a program that computes the Hamming distance between two -dimensional vectors.
Input
The first line contains the number of test cases . ()
Each test case consists of three lines. The first line contains the dimension of the vectors. () The second line contains and the third line contains , separated by spaces. Every entry is an integer between and , inclusive.
Output
For each test case, print the Hamming distance between and , one per line.