Loading...
Loading...
Loading...
Every order has the name of its customer. Count how many orders each customer placed, and print the customers in alphabetical order.
<name> <orders> per customer, sorted by name (capital letters sort before small letters).Example
Input
6 Riya Arjun Riya Meera Arjun Riya
Output
Arjun 2 Meera 1 Riya 3
Arjun 2 orders, Meera 1, Riya 3.
Try the problem first. Open one hint at a time.
A TreeMap keeps its keys sorted, so you do not need a separate sort.
Count with merge(name, 1, (a, b) -> a + b).
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor