Find the Missing Invoice IDs

Medium ⏱ 12 min 59% acceptance ★★★★☆ 4.4
Invoices should be numbered consecutively from start to end (inclusive), but some are missing from the received list. Write missing_invoices(start, end, received) returning a sorted list of the missing IDs.

Examples

Example 1
Input
missing_invoices(1, 5, [1, 2, 5])
Output
[3, 4]
Explanation

IDs 3 and 4 never arrived.

Constraints

  • Range is inclusive on both ends.
  • Return a sorted list.

Topics

Setsdifference

Companies

PayPalRazorpayDeloitte

Hints

Hint 1

Build the full expected set with range().

Hint 2

Set difference, then sorted().

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.