Visitors Active on All Three Days

Medium ⏱ 12 min 59% acceptance ★★★★☆ 4.4
Given three lists of user IDs — one per day — write loyal_visitors(day1, day2, day3) returning a sorted list of the users that appeared on all three days.

Examples

Example 1
Input
loyal_visitors([1, 2, 3], [2, 3, 4], [3, 2, 9])
Output
[2, 3]
Explanation

Only users 2 and 3 show up every day.

Constraints

  • Return a sorted list.
  • Works even if one list is empty (result is empty).

Topics

Setsmulti-set intersection

Companies

MetaGoogleNetflix

Hints

Hint 1

set.intersection can chain across multiple sets.

Hint 2

set(day1) & set(day2) & set(day3).

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