Loading...
Loading...
Loading...
Each payment line has a customer name and the amount paid. Add up the payments of every customer and print the totals in alphabetical order of the name.
<name> <amount>.<name> <total> per customer, sorted by name.Example
Input
6 Riya 250 Arjun 120 Riya 80 Meera 600 Arjun 45 Riya 300
Output
Arjun 165 Meera 600 Riya 630
Riya paid 250 + 80 + 300 = 630.
Try the problem first. Open one hint at a time.
spent.merge(name, amount, (a, b) -> a + b) adds up the payments of one name.
Use Long as the value type: the total can pass two billion.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor