I will Find You and Correct You

3.6

12 votes
Hashing, Easy
Problem

Somnath is a Grammar Nazi. He keeps pointing out others’ grammatical mistakes. However, for a given sentence, he tries to remember all the unique words only so that he can be more efficient with his annoying habit. You wish to join his team to help him with his obsession for Queen’s Language. Given a sentence S, find the number of unique words present in it. S contains only English alphabets in lowercase and ends with a newline character (‘\n’).

Input Format
The first line comprises no. of test cases T. Each of the T lines that follow comprises a sentence containing one or more space-separated words.

Output Format
In each of the T lines, display an integer equal to the number of unique words present in the sentence.

Constraints

1 <= T <= 105
1 <= |S| <= 1050

Sample Input
3
perfection is achieved not when there is nothing more to add but when there is nothing left to take away
you must be the change you wish to see in the world
if the lessons of history teach us anything it is that nobody learns the lessons that history teaches us
Sample Output
14
10
14
Time Limit: 4
Memory Limit: 256
Source Limit:
Contributers:
Editor Image

?