Algorithm · Amazon · Medium
Implement a package tracking system. Packages are numbered with integer IDs starting from 0. They can arrive in any order. You must provide two operations: receive(int id) – records that the package with this id has been received. The same id may be recorded multiple times; duplicate arrivals should be ignored. query() – returns a list containing exactly two items: An integer k: the largest integer such that all packages with IDs 0, 1, 2, ..., k have been received. If no…