Distinct Letter Packet
Preview mode. Log in to edit, run, submit, and save progress.
Easy
Distinct Letter Packet
A packet contains n lowercase symbols captured from a noisy set-notation feed. The same symbol may appear more than once because the feed can repeat observations. For each packet, count how many different symbols are present. Input Format: The first line contains t, the number of test cases. Each test case contains n followed by n lowercase symbols. Output Format: For each test case, print the number of distinct symbols.
Examples
Example 1
Input:
1 4 a b c a
Output:
3
Explanation: The packet contains a, b, and c as distinct symbols.
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