Transaction Fraud Report Part 1 — Verify Data Integrity
Problem statement
Four-part sequence: This is Part 1 of one progressive transaction-fraud interview exercise. Each part extends the previous contract.
- Part 1: Verify Transaction Data Integrity (you are here).
- Part 2: High-Risk Rule Validation.
- Part 3: User Behavior Matching.
- Part 4: Smart Fraud Error Reporting.
Validate the structural integrity of transaction records before any fraud rules run.
Input
Each string in transactions is one unquoted CSV row with exactly six comma-separated fields, in this order: transaction_id,user_id,amount,payment_method,country,hour.
Trim surrounding whitespace from every field. A field containing only whitespace is empty. At this level, validate only whether all six fields are non-empty; do not interpret the numeric fields yet.
Result
Return a two-column string table whose first row is ["transaction_id","status"]. Append one row per transaction in input order.
- Use
OKwhen all six trimmed fields are non-empty. - Use
SUSPICIOUSwhen at least one field is empty. - Keep the trimmed transaction ID in the first column, including an empty string when the ID itself is missing.
Function
validateTransactionIntegrity(transactions: String[]) → String[][]Examples
Example 1
transactions = ["tx1,u1,500,card,US,10","tx2,u2,,cash,CA,20"," ,u3,700,card,US,12","tx4,u4,900, bank , US , 8"]return = [["transaction_id","status"],["tx1","OK"],["tx2","SUSPICIOUS"],["","SUSPICIOUS"],["tx4","OK"]]tx1 and tx4 have six non-empty fields after trimming. tx2 has an empty amount. The third row has an empty transaction ID, so its output ID is also empty.
Example 2
transactions = ["edge,user,0,card, US ,0","blank,user,10,card, ,12"]return = [["transaction_id","status"],["edge","OK"],["blank","SUSPICIOUS"]]The value 0 is non-empty, so the first row passes this level. The second row's country contains only spaces and becomes empty after trimming.
Constraints
1 <= transactions.length <= 10000.- Every row contains exactly six comma-separated fields and no quoted commas.
- Each field contains at most
100characters before trimming. - Rows are processed independently and remain in their original order.