Durable Data Writer
Reported by candidates from Databricks's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Databricks OA reported in July 2025 looks like a simple simulation, and that's the trap. Durable Data Writer hands you five operations, two lists, and a crash rule, and the bugs hide in how you handle state. If you alias a list or forget the READ snapshot, the output comes out wrong on the second read. It's a pure simulation problem with no fancy algorithm. You need two buffers and clean copying. If you blank during the live assessment, StealthCoder runs invisibly as a safety net and gives you the working structure fast.
The problem
Simulate a durable record writer by processing a finite operation sequence. The writer starts in the running state with empty pending and durable storage. Each operation is one of: ["WRITE", record]: append record to the in-memory pending buffer. ["FLUSH"]: atomically append every pending record to durable storage, preserving order, then clear the pending buffer. Flushing an empty buffer does nothing. ["CRASH"]: discard only pending records and enter the crashed state. Durable records remain unchanged. ["RECOVER"]: leave the crashed state with the durable records intact and an empty pending buffer. ["READ"]: return a snapshot of the durable records. Pending records are not visible. After CRASH, the next operation is RECOVER. Return one string array for every READ operation, in operation order. Duplicate records are preserved. Function simulateDurableWriter(operations: String[][]) → String[][] Examples Example 1 operations = [["WRITE","A"],["WRITE","B"],["READ"],["FLUSH"],["READ"]] return = [[],["A","B"]] The first read sees no durable records because both writes are pending. After the flush, both records are durable and visible in order. Example 2 operations = [["WRITE","a"],["FLUSH"],["WRITE","b"],["CRASH"],["RECOVER"],["READ"],["WRITE","c"],["FLUSH"],["READ"]] return = [["a"],["a","c"]] Record a survives because it was flushed. Pending record b is lost in the crash. After recovery, c is written and flushed after a. Constraints 1 <= operations.length <= 10000 Every operation has a valid name and arity. Every record is a non-empty string of at most 100 characters. The total number of WRITE operations is at most 5000. After each CRASH, the next operation is RECOVER.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that there is no trick, only discipline. Keep two lists, pending and durable. WRITE appends to pending. FLUSH extends durable with pending, then clears pending. CRASH clears pending only. RECOVER does nothing to the data, since the crash already dropped pending. READ appends a copy of durable to the result. The edge case that breaks a naive solution is returning a reference to durable instead of a copy. Later flushes then mutate your earlier answers, and Example 2 fails on the first read. Another slip is clearing durable on CRASH. Flushing an empty buffer must be a no-op, which extending with an empty list handles for free. Duplicates stay because you use lists, not sets. It runs in O(n) time with at most 5000 writes. StealthCoder is your hedge in the live OA if the state rules blur under pressure.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Durable Data Writer 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 would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Databricks's OA.
Databricks reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Durable Data Writer FAQ
How hard is the Durable Data Writer problem really?+
Easy on algorithms, medium on carefulness. There's no data structure trick. You track two lists and follow five rules. Most failures come from aliasing the durable list in READ output, not from logic. If you can write a clean switch over operation names, you're fine.
What's the trick to getting it right?+
Copy the durable list on every READ. Store a snapshot, not a reference, or later FLUSH calls will rewrite earlier results. Everything else is mechanical: WRITE to pending, FLUSH moves pending to durable, CRASH wipes pending only.
What happens to pending records on CRASH?+
They're discarded. Durable records stay exactly as they were. In Example 2, record b is lost because it was never flushed, while a survives. RECOVER then just resumes normal operation with an empty pending buffer.
Do I need to validate operations or handle bad input?+
No. The constraints say every operation has a valid name and arity, and every CRASH is followed by RECOVER. Skip defensive checks and spend the time on testing the snapshot behavior and empty flush cases.
How do I prepare for this in 48 hours?+
Practice state-machine simulation problems where you process an operation list and return outputs for some of them. Write this one from scratch twice, test with duplicates, back-to-back flushes, and a read right after recovery. That covers nearly every edge case.