Embercode
✕
HeapsQuick quiz

Scheduler and reorganising in Python

8 questions. Covers Reorganise a string with a max heap in Python.

Questions 1 to 5 of 8

  1. 1. What does this code print? ``python from collections import Counter def formula(tasks, n): counts = Counter(tasks) max_count = max(counts.values()) max_ties = sum(1 for c in counts.values() if c == max_count) return max(len(tasks), (max_count - 1) * (n + 1) + max_ties) print(formula('AABBCCC', 1)) ``
  2. 2. What does this code print? ``python from collections import Counter def possible_by_formula(s): return max(Counter(s).values()) <= (len(s) + 1) // 2 print(possible_by_formula('aaaabbb')) print(possible_by_formula('aaaaabb')) ``
  3. 3. What does this code print? ``python from collections import Counter c = Counter('CABBA') print(c['B'], c['C'], ord('C') - ord('A')) ``
  4. 4. Using the formula from the task scheduler lesson, what is the minimum time for the tasks AAABBB with cooldown n = 3?
  5. 5. Which of these strings has no valid rearrangement in which no two neighbours are equal?

5 question(s) left on this page.