Problem 297842 · easy · Level 02 Linear Data Structures

Shared Attendees

sets · intersection · ordering

Two workshops keep sign-in sheets day1 and day2 (names may repeat if someone signed in twice). Return the names that attended both days, in the order of their first appearance on day1, with no duplicates.

Examples

Input:  day1 = ["ann", "bob", "ann", "cy"], day2 = ["cy", "dee", "ann"]
Output: ["ann", "cy"]

Constraints

  • 0 <= len(day1), len(day2) <= 10**5
  • Target complexity: O(n + m) time.

Goals

  • Use set membership for O(1) lookups
  • Control output order explicitly instead of relying on set order
Starting Python…