This question evaluates a candidate's ability to perform efficient data aggregation, use associative data structures (maps/dictionaries), and reason about time and space complexity when processing large collections of records.
You are given a list of expense records. Each record has:
employee_id
(string)
trip_id
(string)
category
(string, e.g.,
MEAL
,
HOTEL
,
TRANSPORT
)
amount
(integer)
Implement functions to compute aggregated totals:
employee_id
.
employee_id
, return total spend per
trip_id
.
employee_id
, return total spend per
category
.