Clean the Tape
Updated
Problem statement
The prices table contains a market-data tape for three assets. Return a cleaned tape with the columns row_index, timestamp, Asset_1, Asset_2, and Asset_3.
Cleaning rules
- Remove rows that are exact duplicates across
timestampand all three asset columns. - Sort the remaining rows by
timestampin ascending order. - Treat every asset value less than or equal to
0as missing. - For each asset independently, forward-fill a missing value from that asset's most recent positive value in the sorted tape.
- Never backfill. If an asset has no earlier positive value, keep the output value
NULL. - Reset the row index after sorting so that
row_indexis0,1, and so on.
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.
prices
Raw price-tape rows with timezone-neutral whole-second timestamps. Column order is timestamp, Asset_1, Asset_2, Asset_3.
| Column | Type | Nullable | Description |
|---|---|---|---|
| timestamp | Timestamp | No | Timezone-neutral observation time in whole-second YYYY-MM-DD HH:MM:SS precision. |
| Asset_1 | Decimal | Yes | Observed price for Asset_1. |
| Asset_2 | Decimal | Yes | Observed price for Asset_2. |
| Asset_3 | Decimal | Yes | Observed price for Asset_3. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| row_index | Integer | No | Zero-based index after cleaning and sorting. |
| timestamp | Timestamp | No | — |
| Asset_1 | Decimal | Yes | — |
| Asset_2 | Decimal | Yes | — |
| Asset_3 | Decimal | Yes | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- The input contains at least
1row and at most2000rows. - Every timestamp is timezone-neutral and uses whole-second
YYYY-MM-DD HH:MM:SSprecision. - After exact duplicate rows are removed, no two remaining rows share the same
timestamp. - Each asset value is a decimal or
NULL. - An exact duplicate may occur more than once and must contribute only one output row.
- Return rows in ascending
timestamporder with the exact result-column order shown.
More Millennium Online Assessment questions
- Calculate the Half SpreadOA · Seen Sep 2026
- Debug the Impact ModelOA · Seen Sep 2026
- Debug the Risk-Limit QuoterOA · Seen Sep 2026
- Hedge Inventory with Return CovarianceOA · Seen Sep 2026
- Quote One RequestOA · Seen Sep 2026
- Risk Limits and Inventory SkewOA · Seen Sep 2026
- Track the Book and Mark Final PnLOA · Seen Sep 2026
- Client Markout AnalysisOA · Seen Sep 2026
- Debug Fair-Value LookupOA · Seen Sep 2026
- Debug the Tape CleanerOA · Seen Sep 2026
Similar questions at other companies
- Request Routing SystemStripe · OAStripe interview questions
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
- Build Sessions from Unordered Events (Part 1)Scale AI · OAScale AI interview questions
- Prepare Taxi Driver Classification DataBoston Consulting Group · OABoston Consulting Group interview questions
- Macaron Order PriceOpenAI · OAOpenAI interview questions
- Sorted Cyclic Shift Difference SumsCapital One · OACapital One interview questions
- Optimize Package Order by Sorting One WindowAmazon · OA
- Track Received Byte RangesRoblox · OARoblox interview questions
- Temporal Key-Field Database with Prefix ScansThe Trade Desk · OA