FastPrepShortest Path in a Grid with Obstacles Elimination
Problems/Shortest Path in a Grid with Obstacles Elimination

Shortest Path in a Grid with Obstacles Elimination

Bloomberg LP logoBloomberg LP● HardFULLTIMENEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 99% the same as the original report.

You are given an m x n binary grid. A value of 0 is an empty cell and a value of 1 is an obstacle. Start at (0, 0) and move one cell up, down, left, or right.

Return the minimum number of moves needed to reach (m - 1, n - 1) when you may eliminate at most k obstacles. Return -1 when the destination is unreachable.

Function

shortestPath(grid: int[][], k: int) → int

Examples

Example 1

grid = [[0,0,0],[1,1,0],[0,0,0],[0,1,1],[0,0,0]]k = 1return = 6
grid
01200001110200030114000

A shortest route has six moves and eliminates one obstacle.

Example 2

grid = [[0,1,1],[1,1,1],[1,0,0]]k = 1return = -1
grid
012001111112100

Every route to the destination crosses more than one obstacle.

Constraints

  • 1 <= m, n <= 40
  • 1 <= m * n
  • grid[i][j] is 0 or 1.
  • grid[0][0] = grid[m - 1][n - 1] = 0
  • 0 <= k <= m * n

More Bloomberg LP Phone Screen questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Shortest Grid Path with Obstacle EliminationsAmazon · ONSITE INTERVIEW
  • Shortest Grid Path with Obstacle EliminationGoogle · ONSITE INTERVIEWGoogle interview questions
  • Shortest Distance from All BuildingsWaymo · PHONE SCREENWaymo interview questions
  • Shortest Path in a Grid with Obstacles EliminationMercor · PHONE SCREENMercor interview questions
  • Fire Station Response BillLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Shortest Path in a Blocked GridSpotify · PHONE SCREEN
  • Shortest Path in a Binary MatrixMeta · PHONE SCREENMeta interview questions
  • Shortest Increasing Path to a TargetUber · ONSITE INTERVIEWUber interview questions
  • Shortest Path to Food with DirectionsZip · PHONE SCREENZip interview questions
  • Safest Shortest Path Through a GridSnowflake · OASnowflake interview questions

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad SWE Offer Loops: 14 Experiences (Part 2 of 5)
  • Bloomberg New Grad SWE Interviews: 98 Experiences (Part 1 of 5)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int shortestPath(int[][] grid, int k) {
        // write your code here
    }
}
Checking account…