FastPrepMaximum Visibility in a Forest Grid
Problems/Maximum Visibility in a Forest Grid

Maximum Visibility in a Forest Grid

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported with a full grid and visibility matrix in a first-hand Bloomberg 2024 new-grad interview. Row-major order resolves allowed ties.

Each character in forest is open land _ or a tree X. For an open cell, visibility is the number of other open cells visible in the four cardinal directions before a tree or grid boundary blocks the view.

Return [row,column] for the open cell with maximum visibility. Break ties by row-major order. Return [-1,-1] if every cell is a tree.

Function

maximumVisibilityCell(forest: String[]) → int[]

Examples

Example 1

forest = ["___X","_X__","__X_"]return = [0,0]
forest
01230___X1_X__2__X_

The top-left cell sees four other open cells, the maximum.

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[] maximumVisibilityCell(String[] forest) {
      // Write your code here.
    }
}
Checking account…