Skip to main content
Back to problems
Leetcode
Medium
Arrays
Hash Maps
Employee Bonus

Aggregate bonus amounts by employee and return the total bonus for each employee.

Acceptance 100%
Problem Statement

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.
Examples
Sample cases returned by the problem API.

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.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.