Your question is Parse and Aggregate Log Errors. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Adecco One emits application logs in a pipe-delimited format. Given an array of log lines, parse each line, keep only ERROR events from selected services within a half-open time interval, and aggregate the number of occurrences for each error code.
Each valid log line has this format:
timestamp|service|level|error_code|message
The timestamp is an integer, and the message may contain additional pipe characters. Return a dictionary mapping each matching error code to its count. If no lines match, return an empty dictionary.
Implement aggregate_error_counts(logs, allowed_services, start_time, end_time).
logs is a list of strings.allowed_services is a list of service names.start_time is inclusive and end_time is exclusive.ERROR.def aggregate_error_counts(logs, allowed_services, start_time, end_time):