FastPrepReach a Destination Through Scheduled Flights
Problems/Reach a Destination Through Scheduled Flights

Reach a Destination Through Scheduled Flights

Google logoGoogle● MediumNEW GRADINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives flights with origin, destination, departure time, and arrival time, plus a start and target airport. The goal is to decide if you can reach the target, framed as a graph with BFS or DFS. It does not say when a connection is valid, what the starting time is, whether you can board at an equal time, how airports are encoded, or give examples or limits. Here, times are non-negative integers, time 0 is the start, you can depart at or after your current arrival, flights take positive time, and airports are integer IDs. Our version is about 84% the same as the reported question. Another Google onsite report uses a train timetable instead of flights, with departure and arrival stations and times. The task is the same: decide if a time-valid chain of journeys reaches the destination.

There are airportCount airports numbered from 0 through airportCount - 1. Each flight is [origin, destination, departureTime, arrivalTime].

You begin at startAirport at time 0. You may take a flight from your current airport when its departure time is at least your current arrival time. After taking it, your current time becomes its arrival time.

Return whether some valid sequence of flights reaches targetAirport. Taking zero flights is allowed when the start and target are equal.

Function

canReachDestination(airportCount: int, flights: int[][], startAirport: int, targetAirport: int) → boolean

Examples

Example 1

airportCount = 3flights = [[0,1,2,5],[1,2,5,8]]startAirport = 0targetAirport = 2return = true

Take the first flight and arrive at airport 1 at time 5. The second flight departs exactly at time 5, so the connection is valid.

Example 2

airportCount = 3flights = [[0,1,2,6],[1,2,5,8]]startAirport = 0targetAirport = 2return = false

You reach airport 1 at time 6, after its only outgoing flight has departed.

Example 3

airportCount = 4flights = [[1,3,8,10],[0,2,1,4],[2,1,5,7],[0,1,9,12]]startAirport = 0targetAirport = 3return = true

Although the input is unsorted, flights 0→2, 2→1, and 1→3 form a valid itinerary arriving at time 10.

Constraints

  • 1 <= airportCount <= 100000.
  • 0 <= flights.length <= 100000.
  • Every flight has four integers [origin, destination, departureTime, arrivalTime].
  • 0 <= origin, destination < airportCount.
  • 0 <= departureTime < arrivalTime <= 1000000000.
  • 0 <= startAirport, targetAirport < airportCount.

More Google Phone Screen questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Platform Referral RewardsScale AI · OAScale AI interview questions
  • Shipping Starts and Terminal DestinationsIntuit · OAIntuit interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Shortest Paths in a Nonnegative Directed GraphNation with NaMo · PHONE SCREEN
  • Deterministic Secret Santa AssignmentShopify · PHONE SCREENShopify interview questions
  • Minimum Traveling Salesperson TourGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Minimum Completion Time for DAG DependenciesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Work Order Critical PathHadrian · PHONE SCREENHadrian interview questions
  • Top-Down Employee Reporting ForestOkta · ONSITE INTERVIEWOkta interview questions

Interview reports that mention this question

  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google New Grad R1 Flight Reachability and BQ: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • 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 boolean canReachDestination(int airportCount, int[][] flights, int startAirport, int targetAirport) {
        // write your code here
    }
}
Checking account…