Easy · Hash Maps

Find most popular cost books

Given a list of books, each with an id and a cost, return the ids of all books whose cost is the one shared by the most books, in any order.

Examples

Example 1

{
  "books": [
    {"id": "A", "cost": 10},
    {"id": "B", "cost": 20},
    {"id": "C", "cost": 10},
    {"id": "D", "cost": 30},
    {"id": "E", "cost": 20},
    {"id": "F", "cost": 10}
  ]
}

Output: [A, C, F]

Example 2

{
  "books": [
    {"id": "P", "cost": 5},
    {"id": "Q", "cost": 5},
    {"id": "R", "cost": 5},
    {"id": "S", "cost": 8}
  ]
}

Output: [P, Q, R]

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Hash Maps problems