FastPrepTransaction Fraud Report Part 1 — Verify Data Integrity

Transaction Fraud Report Part 1 — Verify Data Integrity

Stripe logoStripe● EasyNEW GRADPHONE SCREEN
Learn

Problem statement

Four-part sequence: This is Part 1 of one progressive transaction-fraud interview exercise. Each part extends the previous contract.

  1. Part 1: Verify Transaction Data Integrity (you are here).
  2. Part 2: High-Risk Rule Validation.
  3. Part 3: User Behavior Matching.
  4. 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 OK when all six trimmed fields are non-empty.
  • Use SUSPICIOUS when 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 100 characters before trimming.
  • Rows are processed independently and remain in their original order.

More Stripe problems

See Stripe hiring insights
public String[][] validateTransactionIntegrity(String[] transactions) {
    // Write your code here
}
transactions["tx1,u1,500,card,US,10","tx2,u2,,cash,CA,20"," ,u3,700,card,US,12","tx4,u4,900, bank , US , 8"]
expected[["transaction_id", "status"], ["tx1", "OK"], ["tx2", "SUSPICIOUS"], ["", "SUSPICIOUS"], ["tx4", "OK"]]
Checking account…