Doubt in a Interview Problem

Правка en2, от apjcoder123, 2025-04-29 21:33:58

Hi community, I came across below interview problems, I just wanna know if we can solve it using DFS. Thanks in advance!

Problem:

Given an origin airport, destination airport, and series of flights determine whether it is possible for a package at the origin to reach the destination. A flight is represented as departure airport, arrival airport, departure time, and arrival time. During the transportation, the time that the package leaves the airport needs to be greater than or equal to the time it arrives at the airport. Please determine whether it is possible for a package transfer from s to t. The package arrived at s at time 0.

  • E.g. 1
  • Origin: "NYC"
  • Destination: "SFO"
  • Flights: NYC → LAX, Departure: 0, Arrival: 4
  • LAX — SFO, Departure: 5, Arrival: 7
  • Output: True
  • E.g 2

  • Origin: "NYC" Destination: "SFO"
  • Flights: NYC →> LAX, Departure: 0, Arrival: 4
  • LAX -> SFO, Departure: 3, Arrival: 5
  • Output: False

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский apjcoder123 2025-04-29 21:35:51 35
en2 Английский apjcoder123 2025-04-29 21:33:58 22
en1 Английский apjcoder123 2025-04-29 21:33:04 966 Initial revision (published)