FastPrepFirst Duplicate Transaction Within Ten Minutes
Problem · Database

First Duplicate Transaction Within Ten Minutes

EasyLenskart logoLenskartFULLTIMEOA

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

transactions
ColumnMeaning
sequence_noOne-based processing position
transaction_idTransaction identifier
transaction_minuteTimestamp 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.

ColumnTypeNullableDescription
sequence_noPKIntegerNo
transaction_idTextNo
transaction_minuteIntegerNo

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
transaction_idTextNo

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • The transactions table has between 1 and 10^5 rows.
  • sequence_no is unique, non-null, and records processing order.
  • transaction_id is a non-null string of length from 1 through 50 and may appear more than once.
  • 0 <= transaction_minute <= 10^9.
  • transaction_minute values are non-decreasing in sequence_no order.

More Lenskart problems