← 返回 doordash 的题目列表Compute Salary with Peak Hours
类型:online_judge
Given a set of order information, where each entry contains the working hours of a delivery person (Dasher), the order's timestamp, and the amount. Calculate the total salary for each delivery person, considering a constant base wage per hour plus an additional fee during peak hours.
Input:
A list containing multiple order entries, each consisting of dasher_id, timestamp, amount
A fixed base wage base_wage
Extra fee during peak hours peak_extra
Time range of peak hours peak_hours
Output:
Total salary for each delivery person, returned in the form of a dictionary with dasher ID as keys and total salary as values.
Example:
orders = [
{'dasher_id': '001', 'timestamp': '2023-11-25T08:00:00', 'amount': 100},
{'dasher_id': '001', 'timestamp': '2023-11-25T09:00:00', 'amount': 150},
]
base_wage = 10
peak_extra = 5
peak_hours = ['08:00', '10:00']
# Returns: {'001': 30}
Follow-up: How would you handle errors in input data, such as incorrect time format?
Example
Input
orders = [{'dasher_id': '001', 'timestamp': '2023-11-25T08:00:00', 'amount': 100}, {'dasher_id': '001', 'timestamp': '2023-11-25T09:00:00', 'amount': 150}]; base_wage = 10; peak_extra = 5; peak_hours = ['08:00', '10:00']
Output
{'001': 30}