← 返回 rippling 的题目列表Validate Expense Reimbursements (Legality Check)
类型:online_judge
Problem: Validate Expense Reimbursements (Legality Check)
You are given a list of employee expense reimbursement records. Implement validation logic to determine whether each reimbursement is legal/valid, and output the validation result for each record.
Input
The input contains multiple reimbursement records.
Each record contains at least the following fields:
employee_id: employee identifier (string or integer)
amount: reimbursement amount (integer or float)
category: expense category (string)
timestamp: submission time (ISO8601 string or integer timestamp)
receipt_id: receipt/invoice identifier (string)
Note: The interview write-up does not specify the exact format; it could be a JSON array, CSV, or line-based text.
Output
For each reimbursement record (in the same order as input), output whether it is valid:
Return a list of results.
Each result should contain at least:
is_valid: boolean
(optional) reason: string describing why it is invalid
Validation rules (to be provided in the interview)
Implement the rules given by the interviewer. Common examples (possible directions only):
Amount must be positive.
Category must be in an allowed set.
Duplicate receipt_id is not allowed.
Timestamp must be within an allowable window (e.g., last 90 days).
Per-transaction / per-day / per-month limits.
Constraints
Not provided in the write-up; typical expectations:
number of records n up to 1e4–1e5
aim for O(n) or O(n log n)
Example test ideas (illustrative only)
Negative amount -> invalid.
Two records share the same receipt_id -> at least one invalid.
Category not allowed -> invalid.
Timestamp out of window -> invalid.
Mixed valid/invalid records -> output per-record results.
Example
Input
[{'employee_id': 'e1', 'amount': -10, 'category': 'MEAL', 'timestamp': '2026-01-01T10:00:00Z', 'receipt_id': 'r1'}]
Output
[{'is_valid': false}]