Skip to content

ORIGINAL CODING QUESTION

Unique practice visitors

Visitor IDs may repeat in the practice log. Count how many distinct integer IDs occurred.

Open practice workspace

Original exercise · easy. Editorial role relevance does not imply a company has asked this question.

Input and output

First integer n, then n visitor IDs. Print the distinct count.

Constraints

1 ≤ n ≤ 10,000; -100,000 ≤ ID ≤ 100,000.

Example 1

Input

6
4 9 4 2 9 7

Output

4

The distinct IDs are 4, 9, 2, and 7.

Example 2

Input

3
8 8 8

Output

1

Repeated visits from one ID count once.

Explain your approach

Explain your time and auxiliary space complexity. Which input makes your algorithm work hardest?

Private grading inputs, expected outputs and canonical reference implementations are withheld. Authored expected outputs were cross-checked with independent reference oracles; compiler/runtime behavior still needs a verified execution provider.

Hint 1

You need membership, not a frequency total.

Hint 2

A set keeps only distinct values.

Hint 3

Insert each ID into a set; return the set size.

Practice this question

Save your work privately, explain decisions and return to your revision queue.

Open practice workspaceBrowse the question library →