Back to problems

Grid pathfinding with time & cost optimality (BFS / shortest path variant)

Algorithm · Databricks · Medium

Given an m x n grid, find a route that starts at the upper-left position (0,0) and finishes at the lower-right position (m-1,n-1). Traveling through the grid accumulates two quantities: time: the overall travel time required to arrive at the destination cost: the total amount paid over the chosen route For each cell, the input provides a pair of non-negative integer weights (time, cost). The input format is: The pairs are given in row-major order, with each pair represented…

Checking your access…