Aggregate bonus amounts by employee and return the total bonus for each employee.
Given a list of bonus records for employees, compute the total bonus credited to each employee.
Each record identifies an employee and the bonus amount associated with that record. If an employee appears multiple times, their bonuses should be added together.
Return the employees with their final bonus totals. The exact output ordering may depend on the platform specification; when not specified, any order that is consistent with the required result is acceptable.
Input Format
- A collection of bonus records.
- Each record contains an employee identifier/name and a bonus amount.
- Employee identifiers may repeat across records.
Output Format
- A collection of employees with their aggregated bonus totals.
Constraints
- Employee identifiers are non-empty.
- Bonus values are integers.
- The number of records is at least 1.
- Use an aggregation approach that handles repeated employees correctly.
Example 1
Input
records = [["Alice", 1000], ["Bob", 500], ["Alice", 700]]
Output
[["Alice", 1700], ["Bob", 500]]
Explanation
Alice appears twice, so her bonuses are summed to 1700. Bob appears once, so his total stays 500.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.