Embercode
✕
HeapsQuick quiz

Meeting rooms in Python

6 questions. Covers Meeting rooms II with a min heap in Python.

Questions 1 to 5 of 6

  1. 1. What does this code print? ``python import heapq ends = [] best = 0 for start, end in [(0, 3), (0, 3), (4, 5)]: while ends and ends[0] <= start: heapq.heappop(ends) heapq.heappush(ends, end) best = max(best, len(ends)) print(best, len(ends)) ``
  2. 2. What does this code print? ``python import heapq ends = [] for start, end in [(0, 30), (30, 60)]: while ends and ends[0] < start: heapq.heappop(ends) heapq.heappush(ends, end) print(len(ends)) ``
  3. 3. Which statements about the two meeting-room methods are true? Choose all that apply.

    Pick every answer that is true.

  4. 4. The heap method frees a finished room by taking the smallest end time out of the heap. Which heapq function does it call for that? Give the function name.

    Type your answer.

  5. 5. In the heap method, what does the heap's size equal at each step?

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.