Debug Fair-Value Lookup
Reported by candidates from Millennium's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Millennium reported this one in September 2026, and the title undersells it. It's a debugging task, not a build-from-scratch query. You get a Pandas starter that almost works, and you have to find four bugs: timestamp order, exact-time rows, invalid prices, and the staleness boundary. Brute force isn't the issue here since the table tops out at 2000 rows. Correctness on edge cases is the issue. If you blank on the as-of logic during the live OA, StealthCoder is the safety net that reads the problem and gives you a working fix. Know the four traps first and you probably won't need it.
The problem
The provided Pandas starter attempts an as-of fair-value lookup, but it mishandles timestamp order, exact-time observations, invalid prices, and the staleness boundary. Fix fair_value_at so it returns a one-row DataFrame with the column price. Lookup rules Read the single row in query_params and convert all timestamps before comparing them. Consider only price rows whose timestamp is at or before query_time. Starting with the most recent eligible row, walk backward until the requested asset has a non-null, strictly positive price. If no valid observation exists, return NULL. Otherwise, calculate the candidate's age from its own timestamp. Return NULL only when that age is strictly greater than max_staleness_minutes; an observation exactly on the boundary is accepted. Tables prices: timestamp PK (Timestamp), Asset_1 (Decimal), Asset_2 (Decimal), Asset_3 (Decimal) query_params: asset (Text), query_time (Timestamp), max_staleness_minutes (Integer) Constraints The prices table contains at least 1 row and at most 2000 rows. Price timestamps are unique but may arrive out of order. The query_params table contains exactly one row. The requested asset is exactly Asset_1, Asset_2, or Asset_3. max_staleness_minutes is a nonnegative integer. Return exactly one row; its price may be NULL.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is an as-of lookup with a fallback filter. Convert timestamps to real datetimes first, since string comparison breaks ordering. Filter rows where timestamp <= query_time, so an exact-time row counts. Then drop rows where the requested asset column is null or <= 0, sort by timestamp descending, and take the first one. That replaces the walk-backward loop cleanly. Sort explicitly, because rows can arrive out of order. Now compute age in minutes from that candidate's own timestamp, not from the latest row overall. Return NULL only if age > max_staleness_minutes, so age equal to the limit passes. The classic pitfalls: using < instead of <=, checking staleness before skipping invalid prices, and returning an empty frame instead of one row with a NULL price. StealthCoder is the hedge if the live OA catches you mid-bug, but the logic fits in about eight lines.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Debug Fair-Value Lookup cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Millennium's OA.
Millennium reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Debug Fair-Value Lookup FAQ
How hard is the Millennium Debug Fair-Value Lookup question really?+
Easy on algorithm, tricky on details. With 2000 rows max, no optimization is needed. The difficulty is spotting four separate bugs in the starter: unsorted timestamps, excluding exact-time rows, accepting null or non-positive prices, and an off-by-one staleness check.
What's the core trick for the as-of lookup?+
Filter to timestamp <= query_time, remove null and non-positive prices for the requested asset, sort by timestamp descending, and take the top row. Only then check staleness against that row's own timestamp. Order of those steps matters.
How should I handle the staleness boundary?+
Return NULL only when age in minutes is strictly greater than max_staleness_minutes. If the age equals the limit, the price is valid. Use > in your comparison, not >=. This is the most common off-by-one in this problem.
What should I return when no valid price exists?+
Still return a one-row DataFrame with the column price, holding NULL (None or NaN). Don't return an empty frame. The spec says exactly one row, always, and the price may be NULL.
How do I prepare for this in 48 hours?+
Practice Pandas basics: pd.to_datetime, boolean filtering, sort_values, and building a one-row DataFrame. Then write the as-of lookup yourself and test edge cases: exact-time match, invalid latest price, age exactly on the limit, and out-of-order input.