← 返回 stripe 的题目列表Parse and Aggregate Records with Potentially Unknown Fields
类型:online_judge
Problem: Parse and Process a Batch of Records (Fields May Vary)
You are given an input containing multiple records. Each record contains a set of fields in key=value format (the set of fields may not be fully fixed; some test cases may include fields not seen elsewhere).
You need to:
Parse all records from the input;
Apply the required business rules to aggregate/stat/transform the records;
Output the result in the required format.
Input Format
The first line: an integer n, the number of records.
The next n lines: each line is one record consisting of key=value fields separated by spaces.
Output Format
Output the aggregated/statistical results as required by the prompt (exact format depends on the original statement).
Constraints
Your solution should be robust to:
Missing fields
Additional/unknown fields
Arbitrary field ordering
Duplicate fields within a record (define behavior if allowed)
Sample Tests (Format Examples)
Note: The original post does not include the exact business rules and expected output. The following are only input-format examples.
Input:
3
id=1 amount=10 currency=USD
id=2 amount=5 currency=USD
id=3 amount=7 currency=EUR
Output:
(as specified by the prompt)
Input:
2
id=1 amount=10 currency=USD extra=foo
id=2 currency=USD
Output:
(as specified by the prompt)
Input:
1
id=1 amount=0 currency=USD
Output:
(as specified by the prompt)
Input:
1
id=1 amount=10
Output:
(as specified by the prompt)
Input:
0
Output:
(as specified by the prompt)
Example
Input
3
id=1 amount=10 currency=USD
id=2 amount=5 currency=USD
id=3 amount=7 currency=EUR
Output
(as specified by the prompt)