FastPrepMutual Station Connectivity Queries
Problems/Mutual Station Connectivity Queries

Mutual Station Connectivity Queries

Bloomberg LP logoBloomberg LP● HardNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The source gives a directed network of stations and queries about whether two stations can reach each other. A discussion supports using strongly connected components so each query takes constant time. We added how indexes are written, input limits, and the usual rule that a station can reach itself. Our version is about 94% the same as the reported question.

A directed subway network has stations labeled from 0 through n - 1. Each row [from, to] in connections means trains can travel directly from from to to.

For each row [a, b] in queries, determine whether a can reach b and b can reach a through zero or more directed connections. A station is mutually reachable with itself.

Return the query answers in order.

Function

mutuallyConnected(n: int, connections: int[][], queries: int[][]) → boolean[]

Examples

Example 1

n = 5connections = [[0,1],[1,2],[2,0],[2,3],[3,4],[4,3]]queries = [[0,2],[0,3],[3,4],[4,0],[1,1]]return = [true,false,true,false,true]

Stations 0, 1, 2 form one strongly connected component, while 3, 4 form another. The edge from 2 toward 3 does not provide a path back.

Example 2

n = 4connections = [[0,1],[1,0],[2,3]]queries = [[0,1],[0,2],[2,3],[3,3]]return = [true,false,false,true]

Only stations 0 and 1 are distinct mutually reachable stations. The one-way edge 2 → 3 is insufficient, and a station always reaches itself.

Example 3

n = 1connections = []queries = [[0,0]]return = [true]

The only station is mutually reachable with itself through a zero-edge path.

Constraints

  • 1 <= n <= 100000.
  • 0 <= connections.length <= 200000.
  • 1 <= queries.length <= 100000.
  • Every station index in connections and queries is between 0 and n - 1.
  • Connections may contain self-loops or duplicate edges.

More Bloomberg LP Phone Screen questions

  • 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
  • Trapping Rain WaterPHONE 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

Similar questions at other companies

  • Spreadsheet With Dependent CellsCharacter.AI · PHONE SCREEN
  • Evaluate Live Spreadsheet ExpressionsStrala · PHONE SCREEN
  • Spreadsheet Formula EvaluatorPika · PHONE SCREEN
  • Spreadsheet Formula DependenciesAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Periodic-Color Binary Forest RootsGoogle · PHONE SCREENGoogle interview questions
  • Spreadsheet Formula EvaluatorHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
  • Find Trapped ZonesServiceNow · PHONE SCREENServiceNow interview questions
  • Spreadsheet Formula DependenciesCitadel · PHONE SCREENCitadel interview questions
  • Versioned Friend RecommendationsOpenAI · PHONE SCREENOpenAI interview questions
  • Visit Desired Attractions Without Reusing a TrailDuolingo · PHONE SCREENDuolingo interview questions

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad SWE Interviews: 98 Experiences (Part 1 of 5)

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)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public boolean[] mutuallyConnected(int n, int[][] connections, int[][] queries) {
        // Write your code here.
    }

}
Checking account…