Mobile coding works. A laptop is faster for long sessions.
Problem
Read integers from standard input, separated by spaces or
newlines, until end of input (`EOF`). Determine and print
how many **distinct** values appear in the sequence.
**The data are read from standard input** (in the format described), not from a
file. Use `while (cin >> x)` to detect end of input.
Input:
One or more lines contain integers, separated by
spaces or newlines.
- the total number of values read is between `0` and `1000`
- values are integers between `-1.000.000` and `1.000.000`
Output:
The program prints to standard output a single non-negative integer: how many
distinct values were read. If the input is empty, the program prints
`0`.
Example:
Input:
1 2 3 2 1 4 5 3
Output:
5
Stuck?
Use the Get Hint button in the action bar to reveal a guided hint.
💬 Discussion
Loading...💬
No comments yet. Be the first to start the discussion!
💻 No output yet.
Click Run in the editor to execute your code with the custom input.
Solve it your way first
Community solutions unlock after you submit a passing solution. Don't peek.
Ready to solve this challenge?
Create a free account to write code, submit solutions, and track your progress.
⌨️ Keyboard Shortcuts
Code Editor
Run Code
Ctrl
Enter
Submit Code
Ctrl
Shift
Enter
Format Code
Shift
Alt
F
Toggle Comment
Ctrl
/
Undo
Ctrl
Z
Redo
Ctrl
Y
Navigation
Global Search
/
Show Shortcuts
?
Close Modal
Esc