Problem · Database
First Duplicate Transaction Within Ten Minutes
Problem statement
The table transactions stores transaction records in processing order. A row is a duplicate when an earlier row has the same transaction_id and occurred no more than 10 minutes before it.
Scan rows by sequence_no. Return the transaction_id from the first duplicate row encountered. If no duplicate exists, return NONE.
Transaction IDs may recur; each recurrence is compared with the most recent earlier occurrence of the same ID.
Input table
| Column | Meaning |
|---|---|
sequence_no | One-based processing position |
transaction_id | Transaction identifier |
transaction_minute | Timestamp in minutes |
Table schema
MySQLPostgreSQLPandas
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
transactions
One transaction row per processing position.
| Column | Type | Nullable | Description |
|---|---|---|---|
| sequence_noPK | Integer | No | — |
| transaction_id | Text | No | — |
| transaction_minute | Integer | No | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| transaction_id | Text | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- The
transactionstable has between1and10^5rows. sequence_nois unique, non-null, and records processing order.transaction_idis a non-null string of length from1through50and may appear more than once.0 <= transaction_minute <= 10^9.transaction_minutevalues are non-decreasing insequence_noorder.