FastPrepDirectional Distance to Mines and Boundaries
Problems/Directional Distance to Mines and Boundaries

Directional Distance to Mines and Boundaries

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported with the exact two-pass optimization goal in a first-hand Bloomberg early-career phone screen.

Given a grid mines where 1 is a mine and 0 is an open cell, return a grid of the same size with one value per cell.

For an open cell, look up, down, left and right. In each direction, count the open cells before the first mine or the grid edge, not counting the cell itself. The cell's value is the sum of the four counts. A mine cell gets 0.

Function

directionalDistances(mines: int[][]) → int[][]

Examples

Example 1

mines = [[0,0,1],[0,0,0]]return = [[2,2,0],[3,3,2]]

The bottom-left cell has two open cells to its right and one above it, so its value is three. The top-right cell is a mine, so its value is zero.

Constraints

  • The rectangular grid has at most 10^6 cells.

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

  • Unique Grid PathsMorgan Stanley · PHONE SCREENMorgan Stanley interview questions
  • Count Starts Reaching a Grid MaximumDuolingo · PHONE SCREENDuolingo interview questions
  • Find Robots by Blocker DistancesUber · PHONE SCREENUber interview questions
  • Count Bounded Diagonal Grid PathsGoogle · PHONE SCREENGoogle interview questions
  • Factory Cost — Minimum Cost Across StagesStripe · PHONE SCREENStripe interview questions
  • Path Through an O/X Grid Using Only Right and DownAmazon · PHONE SCREEN
  • 3D Grid Diagonal Walk ProbabilityApple · PHONE SCREENApple interview questions
  • Maximum Rocks on a North-or-East Grid PathGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Maximal SquareAirwallex · PHONE SCREENAirwallex interview questions
  • Maximal SquareSalesforce · PHONE SCREENSalesforce interview questions

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
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[][] directionalDistances(int[][] mines) {
      // Write your code here.
    }
}
Checking account…