Software Engineer • Mid-Level
Software Engineer • Mid-Level
High QualityPrep Other Coding Questions Asked by Databricks
Continue with targeted prep from Databricks's coding question bank.
Interview Summary
My Databricks phone screen included a grid problem about choosing the fastest way to commute across San Francisco. I had to return the name of the transportation mode that got me from home to the office in the least time, using total cost to break a tie. A route was valid only if I could use the same mode for the entire trip.
Interview Details
Technical Phone Screen — Find the Optimal Commute
I was given a map with one home (S), one office (D), and roadblocks marked X. Each numbered cell belonged to one transportation mode, and three arrays supplied the mode names, minutes per block, and dollars per block. The grid could be up to 100 × 100, with at most 10 modes.
I could move up, down, left, or right. Once I stepped onto a numbered cell, I had to stay on cells with that same number until I reached the office. If no single mode connected home to work, the expected return value was "".
One detail mattered when comparing routes: the time and cost came from the cell I was leaving. Stepping out of S was free, but stepping off the last numbered cell into D counted. A route written as S → 2 → 2 → D therefore incurred two blocks of time and cost.
These three examples illustrate how the return value works. Each quoted string represents one grid row.
| Grid rows, top to bottom | Per-block time and cost | Expected result |
|---|---|---|
["1111", "SXXD", "2222"] | 1 = Walk (3 min, $0), 2 = Bike (2 min, $1) | "Bike" — both routes cover four numbered cells. Biking takes 8 minutes and walking takes 12. |
["S1", "2D"] | 1 = Walk |
Unlock Full Details
Create a free account to unlock this interview experience report.