Problem · Intervals

Get Meeting Intervals (Google Bangalore)

MediumGoogleFULLTIMEONSITE INTERVIEW
See Google hiring insights

  • You have a list of meetings in your calendar with a start and end time.
  • You are very busy, so meetings can overlap.
  • You also have one "Do Not Schedule" (DNS) interval during which you don't attend any meeting.
  • Any meeting schedule that overlaps with a DNS slot is automatically cut such that it does not overlap with the DNS slot anymore.
  • Return a list of non-overlapping time intervals when you are in a meeting.

    Function Description

    Complete the function getMeetingIntervals in the editor.

    getMeetingIntervals has the following parameters:

    1. 1. int[][] meetings: an arr of intervals representing meeting times
    2. 2. Interval dns: an interval representing the "Do Not Schedule" time

    Returns

    int[][]: an arr of non-overlapping intervals when you are in a meeting

    Examples
    01 · Example 1
    meetings = [[1, 7], [5, 10], [12, 30], [22, 30], [40, 50], [60, 70]]
    dns = [18, 25]
    return = [[1, 10], [12, 18], [25, 30], [40, 50], [60, 70]]
    🦔
    More Google problems
    drafts saved locally
    public int[][] getMeetingIntervals(int[][] meetings, int[] dns) {
      // write your code here
    }
    
    meetings[[1, 7], [5, 10], [12, 30], [22, 30], [40, 50], [60, 70]]
    dns[18, 25]
    expected[[1, 10], [12, 18], [25, 30], [40, 50], [60, 70]]
    sign in to submit