Loading...
Loading...
Loading...
An online store logs the product id of every item ordered today. Some products were ordered many times. Count how many different products were ordered.
Example
Input
6 P10 P22 P10 P31 P22 P10
Output
3
Three different ids: P10, P22 and P31.
Try the problem first. Open one hint at a time.
A set keeps each value once, so its size is the answer.
Add every id to a HashSet<String>, then print size().
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor