FastPrepMinimum Teleporter Repairs
Problems/Minimum Teleporter Repairs

Minimum Teleporter Repairs

Google logoGoogle● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The Google DS/MLE onsite report describes directed teleporters between countries, a repair that takes one day at broken departure nodes, and a zero-repair example that we kept. We chose the indexing, what happens when a place is unreachable or repeated, and the input limits. Our version is about 95% the same as the reported question.

Countries have directed teleport connections. Some countries have a broken departure teleporter, which takes one day to repair before it can be used. Find the minimum number of repair days needed to travel from source to destination; teleporting itself takes zero days.

For this exercise, assume countries are numbered 0..n-1, and each [a,b] connection permits travel from a to b. A broken teleporter belongs to its departure country, regardless of which outgoing connection is chosen. Arrival at a broken destination does not require repair. A teleporter stays repaired after its first repair; an optimal route can be chosen without repeated countries.

For this exercise, return -1 if no directed route exists and 0 if the endpoints coincide. Repeated edges and repeated entries in broken do not change the answer.

Function

minTeleporterRepairs(n: int, connections: int[][], broken: int[], source: int, destination: int) → int

Examples

Example 1

n = 7connections = [[0,1],[0,2],[0,3],[1,2],[1,5],[2,3],[2,4],[2,5],[3,4],[3,6],[5,6]]broken = [5]source = 1destination = 6return = 0

The path 1 -> 2 -> 3 -> 6 avoids departing from the broken teleporter at 5.

Example 2

n = 7connections = [[0,1],[0,2],[0,3],[1,2],[1,5],[2,3],[2,4],[2,5],[3,4],[3,6],[5,6]]broken = [1,5]source = 1destination = 6return = 1

Every nontrivial route departs from the broken source at 1, but 1 -> 2 -> 3 -> 6 requires no additional repair.

Example 3

n = 2connections = [[0,1]]broken = []source = 1destination = 0return = -1

There is no directed route from country 1 back to country 0.

Constraints

  • For this exercise, assume 1 <= n <= 2000 and at most 10000 directed connections.
  • Every country index, including endpoints and broken entries, lies in [0,n-1].
  • broken.length <= 2000; repeated entries and self-connections are allowed.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Cheapest Flights Within K StopsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Fire Station Response BillLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Minimum Friend API CallsMercor · ONSITE INTERVIEWMercor interview questions
  • Shortest Increasing Path to a TargetUber · ONSITE INTERVIEWUber interview questions
  • Find and Reconstruct a Binary-Matrix PathMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Open the Lock and Return a Shortest PathZip · PHONE SCREEN · ONSITE INTERVIEWZip interview questions
  • Shortest Travel Time in a Grid with Traffic LightsWaymo · PHONE SCREENWaymo interview questions
  • Delivery Management SystemAkuna Capital · OAAkuna Capital interview questions
  • Shortest Word Chain Between Two WordsFanatics · PHONE SCREEN
  • Shortest Path from an Encoded GraphIntuit · OAIntuit interview questions

Interview reports that mention this question

  • Google SWE III ML Experienced Loops: 10 Experiences (Part 3 of 4)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int minTeleporterRepairs(int n, int[][] connections, int[] broken, int source, int destination) {
        // Write your code here
    }
}
Checking account…