def flight_sequences_overlap(path1: List[str], path2: List[str]) -> bool: """Return True iff flight sequences path1 and path2 overlap: if the last x number of stops (where x >= 1) of path1 are identical to the first x number of stops of path2. Precondition: - both path1 and path2 are valid flight sequences - the airport codes in each flight path is unique (i.e. we will never have a path where we visit the same airport more than once) >>> path1 = ['AA1', 'AA2'] >>> path2 = ['AA2', 'AA3'] >>> flight_sequences_overlap(path1, path2) True >>> path3 = ['AA1', 'AA2', 'AA3'] >>> path4 = ['AA2', 'AA3', 'AA4'] >>> flight_sequences_overlap(path3, path4) True >>> path5 = ['AA2', 'AA3'] >>> path6 = ['AA1', 'AA3', 'AA2'] >>> flight_sequences_overlap(path5, path6) False """ pass

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18SA
icon
Related questions
icon
Concept explainers
Question

def flight_sequences_overlap(path1: List[str], path2: List[str]) -> bool:
"""Return True iff flight sequences path1 and path2 overlap: if the last
x number of stops (where x >= 1) of path1 are identical to the
first x number of stops of path2.

Precondition:
- both path1 and path2 are valid flight sequences
- the airport codes in each flight path is unique (i.e. we will
never have a path where we visit the same airport more than once)

>>> path1 = ['AA1', 'AA2']
>>> path2 = ['AA2', 'AA3']
>>> flight_sequences_overlap(path1, path2)
True

>>> path3 = ['AA1', 'AA2', 'AA3']
>>> path4 = ['AA2', 'AA3', 'AA4']
>>> flight_sequences_overlap(path3, path4)
True

>>> path5 = ['AA2', 'AA3']
>>> path6 = ['AA1', 'AA3', 'AA2']
>>> flight_sequences_overlap(path5, path6)
False
"""

pass

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr