FastPrepEnumerate Right-and-Down Matrix Paths
Problems/Enumerate Right-and-Down Matrix Paths

Enumerate Right-and-Down Matrix Paths

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a firsthand Bloomberg new grad phone interview. Here you return path strings made of D and R in alphabetical order, instead of printing coordinates.

Given a non-empty rectangular binary matrix grid, return every path from the top-left cell to the bottom-right cell, sorted in lexicographic order. A cell with 1 is valid, and a cell with 0 is blocked.

Each move goes exactly one cell Down or one cell Right, and every cell the path visits must contain 1. Write a path as a string of its moves, using 'D' for Down and 'R' for Right. Lexicographic order sorts strings like a dictionary: compare them character by character, and at the first difference 'D' comes before 'R'.

If no path exists, including when the top-left or bottom-right cell is blocked, return an empty list. A valid 1-by-1 matrix has one path: the empty string.

Function

enumeratePaths(grid: int[][]) → List<String>

Examples

Example 1

grid = [[1,1,1],[1,1,1]]return = ["DRR","RDR","RRD"]
grid
01201111111

Every cell is valid, so all three paths work. With 'D' before 'R', they sort as "DRR", "RDR", then "RRD".

Example 2

grid = [[1,0],[1,1]]return = ["DR"]
grid
01010111

The cell to the right of the start is blocked, so the only path goes Down, then Right.

Example 3

grid = [[1]]return = [""]
grid
001

The start is already the destination, so the only path has no moves and is the empty string.

Example 4

grid = [[1,0],[0,1]]return = []
grid
01010101

Both first moves lead into blocked cells, so no path reaches the destination and the list is empty.

Constraints

  • 1 <= grid.length <= 100 and 1 <= grid[i].length <= 100.
  • Every row has the same length.
  • Every cell is either 0 or 1.
  • The total number of valid paths is at most 10000.

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

  • Word Path Moving Only Right or DownIndeed · PHONE SCREENIndeed interview questions
  • Word Path Moving Only Right or DownWayfair · PHONE SCREENWayfair interview questions
  • Enumerate Right-and-Down Matrix PathsOracle · ONSITE INTERVIEWOracle interview questions
  • Find a Word Path Moving Right or DownIntuit · OAIntuit interview questions
  • Count Eight-Neighbor Unlock PatternsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Empty ShelfSquarepoint Capital · OASquarepoint Capital interview questions
  • Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
  • 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

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 List<String> enumeratePaths(int[][] grid) {
      // write your code here
    }
}
Checking account…