Interview Questions/Coding/Unique Copy Archive

Unique Copy Archive

Preview mode. Log in to edit, run, submit, and save progress.

Easy

Unique Copy Archive

An archive receives n document fingerprints. Duplicate copies of the same fingerprint may arrive many times, but the archive only needs to keep one copy of each distinct fingerprint. For every archive batch, report how many unique fingerprints must be stored. Input Format: The first line contains t, the number of test cases. Each test case contains n followed by n fingerprint values. Output Format: For each test case, print the number of unique fingerprints.

Examples

Example 1
Input:
1
5
1 2 2 3 1
Output:
3

Explanation: The unique fingerprints are 1, 2, and 3.

Approach hint

Start with the simplest clear approach, explain the trade-off, then move toward the cleaner answer.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp