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

Time Limit: 4
Memory Limit: 256
Source Limit:
Editor Image

?