Databricks | Technical Phone screen | BFS
Anonymous User
8368
Feb 12, 2025
Feb 14, 2025

Got a graph based question to find the shortest and cheapest route from source to destination.

Gave the correct solution and interviewer seemed happy with the solution. Got an email (automated, not even from the recruiter) with a rejection.

No feedback given as to what went wrong. When reached out to the recruiter for feedback, they ghosted me and didn't reply.

Question:

Given a 2D grid of a city with source and destination and roadblocks (X)

1 2 3 S 1 2 4
X 2 3 2 1 X 2
2 1 1 D 2 X 4

‘1’, ‘2’, ‘3’, ‘4’ → different Modes of transport

1D array time[], where time[i] represents the travel time per move for transport mode i.
1D array cost[], where cost[i] represents the total cost of using transport mode i.

Movement Rules:
Can move up, down, left, or right.
Cannot switch modes once you pick one mode.
Cannot move through roadblocks (X).

Goal:
Return the mode of transport that results in the fastest path from S to D.
If multiple modes have the same minimum time, return the one with the lowest cost.

Comments (8)