Skip to content

Latest commit

 

History

History
16 lines (11 loc) · 1006 Bytes

File metadata and controls

16 lines (11 loc) · 1006 Bytes

14. Inflight Entertainment

Problem Description

You've built an inflight entertainment system with on-demand movie streaming. Users on longer flights like to start a second movie right when their first one ends, but they complain that the plane usually lands before they can see the ending. You're building a feature for choosing two movies whose total runtimes will equal the exact flight length.

Write a function that takes an integer flightLength (in minutes) and an array of integers movieLengths (in minutes) and returns a boolean indicating whether there are two numbers in movieLengths whose sum equals flightLength.

Implementation

Relying a hashtable, in the worst-case my implementation will return a result in O(n) time complexity, with O(n) space complexity.