Level: Senior-Level
Round: Phone Screen · Type: Coding · Difficulty: 7/10 · Duration: 60 min · Interviewer: Neutral
Topics: Graph Traversal, Breadth-First Search
Location: San Francisco Bay Area
Interview date: 2026-02-15
Got offer: False
I was asked to find the fastest and least expensive route to the Databricks headquarters, given a grid representing San Francisco city blocks and the time/cost matrices for different transportation modes.
The problem given to me was to find the best commute to Databricks HQ. I was given a 2D grid representing the city blocks, with S as the source and D as the destination. X represents a roadblock. The numbers 1-4 represent the transportation modes (1=Walk, 2=Bike, 3=Car, 4=Train). Diagonal traversal is not allowed, and I can only move to neighboring cells with the same transportation mode. I was also given a cost matrix and a time matrix. The goal is to find the fastest mode of transportation, and if there are multiple such modes, then return the one with the least cost.
` /** You live in San Francisco city and want to minimize your commute time to the Databricks HQ.
Given a 2D matrix of the San Francisco grid and the time as well as cost matrix of all the available transportation modes, return the fastest mode of transportation. If there are multiple such modes then return one with the least cost.
Rules:
Sample Input:
2D Grid: Legend: |3|3|S|2|X| X = Roadblock |3|1|1|2|X| S = Source |3|1|1|2|2| D = Destination |3|1|1|1|D| 1 = Walk, 2 = Bike, 3 = Car, 4 = Train |3|3|3|3|4| |4|4|4|4|4|
Cost Matrix (Dollars/Block): [0, 1, 3, 2] Time Matrix (Minutes/Block): [3, 2, 1, 1] */ `