FastPrepAll Paths From Source to Target
Problems/All Paths From Source to Target

All Paths From Source to Target

Bloomberg LP logoBloomberg LP● MediumNEW GRADFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in several firsthand Bloomberg phone and onsite interviews for new grad and full-time roles. Some versions used city and airport labels. Here the graph is a DAG with nodes labeled 0 through n-1.

Given a directed acyclic graph as an adjacency list graph, return every path from node 0 to node n - 1.

Each returned path includes both endpoints. Visit outgoing neighbors in their listed order and return paths in the resulting depth-first order.

Function

allPathsSourceTarget(graph: int[][]) → List<List<Integer>>

Examples

Example 1

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

The two directed routes go through node 1 or node 2.

Example 2

graph = [[4,3,1],[3,2,4],[3],[4],[]]return = [[0,4],[0,3,4],[0,1,3,4],[0,1,2,3,4],[0,1,4]]

Depth-first traversal follows each adjacency list in its supplied order.

Constraints

  • 2 <= graph.length <= 15.
  • Every neighbor is a valid node index and the graph is acyclic.
  • The input contains no duplicate outgoing edge.

More Bloomberg LP Onsite Interview questions

  • 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
  • Word SearchOA · PHONE 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
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Park Train Cars by PreferenceMercor · ONSITE INTERVIEWMercor interview questions
  • Count Prefix Paths in a Character GraphGoogle · PHONE SCREENGoogle interview questions
  • Directional Tiles: Find a Valid Reconfiguration PathDuolingo · PHONE SCREENDuolingo interview questions
  • Attraction Route Without Reusing TrailsWhatNot · PHONE SCREENWhatNot interview questions
  • Enumerate Directed Paths and CyclesByteDance · PHONE SCREENByteDance interview questions
  • Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Package Install OrderVerily · ONSITE INTERVIEW
  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN
  • Course SchedulePlaud · ONSITE INTERVIEW
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions

Interview reports that mention this question

  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 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<List<Integer>> allPathsSourceTarget(int[][] graph) {
      // Write your code here.
    }
}
Checking account…