KatInterview

Find Days Available to All Participants

Arrays & HashingAuto-graded · 18 test cases
EasyAuto-gradedArrays & Hashingsetsintersectionarrays

Last updated

Tests set intersection logic and handling of multiple collections to find common elements across all inputs.

You are building a scheduling tool that helps teams find meeting times. Each team member provides a list of day numbers when they are free to meet.

Write a function that takes a list of availability schedules (one per person) and returns the day numbers when all participants are available, sorted in ascending order.

Each schedule is represented as a list of integers, where each integer is a day number. Day numbers can appear in any order within a schedule and may contain duplicates.

If no common days exist across all schedules, return an empty list. If the input is empty (no participants), return an empty list.

Constraints

  • 0 ≤ number of participants ≤ 100
  • 0 ≤ days per participant ≤ 1000
  • Day numbers are non-negative integers
  • Days within one participant's schedule may be unsorted or contain duplicates
  • The output must be sorted in ascending order with no duplicates

Examples

Example 1

Input: common_available_days([[1, 2, 3], [2, 3, 4], [0, 2, 3]])

Output: [2, 3]

Example 2

Input: common_available_days([[1, 5, 7], [5, 7], [5, 6, 7]])

Output: [5, 7]

Hints

Hint 1

Consider using set operations to efficiently find elements that appear in all collections.

Hint 2

Duplicates within one person's schedule should be treated as a single availability.

Hint 3

Starting with the shortest schedule can reduce unnecessary comparisons.