Loading...
Loading...
Loading...
Two lists hold the names of customers who ordered in January and in February. A customer can appear more than once in a list. Build a report that compares the two months.
Both: ..., Only January: ..., Only February: ... and Total: k. Each list is in alphabetical order, separated by single spaces; an empty list is written as -. k is the number of different customers in the two months together.Example
Input
4 Rohan Priya Rohan Aarav 3 Priya Diya Diya
Output
Both: Priya Only January: Aarav Rohan Only February: Diya Total: 4
Priya is in both months; Total counts Aarav, Diya, Priya and Rohan.
Try the problem first. Open one hint at a time.
Build two TreeSets, one per month.
Both = intersection, Only January = difference, Total = size of the union; always work on copies.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor