String Manipulation
Submissions: 3693   Accuracy:

39.05%

  Difficulty: Easy   Marks: 2

Tom is a string freak. He has got sequences of  n words to manipulate. If in a sequence, two same words come together then he’ll destroy each other. He wants to know the number of words left in the sequence after this pairwise destruction.
 

Input:
The first line of input contains an integer denoting the no of test cases. Then T test cases follow. Each test case contains two lines. The first line of input contains an integer n denoting the number of words in a sequence. In the second line are n space separated words of the sequence. Words are contiguous stretches of printable characters delimited by white space.
 

Output:
For each test case in a new line print the number of words left per sequence.
 

Constraints:
1<=T<=100
1<=n<=100

 

Example:
Input:

2
5
ab aa aa bcd ab
4
tom jerry jerry tom

Output:
3
0

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal
Author: Amit Khandelwal 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.