FastPrepFour-Direction Unique Grid Paths
Problems/Four-Direction Unique Grid Paths

Four-Direction Unique Grid Paths

Bloomberg LP logoBloomberg LP● HardNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a firsthand Bloomberg new grad onsite in 2019, as a follow-up to Unique Paths. Simple paths and strings of D, L, R, and U keep the four-direction version finite and the same everywhere.

In a binary grid, 1 is passable and 0 blocked. Return every simple path from the start cell to the end cell using Down, Left, Right, or Up moves. A simple path visits no cell more than once.

Encode paths with letters D, L, R, U and return them lexicographically.

Function

allGridPaths(grid: int[][], startRow: int, startCol: int, endRow: int, endCol: int) → String[]

Examples

Example 1

grid = [[1,1],[1,1]]startRow = 0startCol = 0endRow = 1endCol = 1return = ["DR","RD"]
grid
01011111
→
return
010DR1RD
Moved or new

The two simple shortest paths use Down-Right and Right-Down.

Constraints

  • At most 16 cells are passable.
  • Start and end are valid grid coordinates.

More Bloomberg LP Onsite Interview questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Word Search IIAmazon · ONSITE INTERVIEW
  • Enumerate Top-to-Bottom Grid PathsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Check Each Word in a Character GridZillow · ONSITE INTERVIEWZillow interview questions
  • Word SearchMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
  • Trace a Word Through a Letter GridExpedia · ONSITE INTERVIEWExpedia interview questions
  • Find a Word in a Letter GridMeta · ONSITE INTERVIEWMeta interview questions
  • Word Search IIApple · PHONE SCREENApple interview questions
  • Word SearchCognitiv · PHONE SCREEN
  • Find a Word in a Letter GridAdobe · PHONE SCREENAdobe 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 String[] allGridPaths(int[][] grid, int startRow, int startCol, int endRow, int endCol) {
      // Write your code here.
    }
}
Checking account…