Embercode
✕
Dicts and SetsQuick quiz

Anagrams and consecutive runs

8 questions. Covers Longest consecutive sequence with a Python set.

Questions 1 to 5 of 8

  1. 1. Why can't a Python list of 26 letter counts be used directly as a dict key for grouping anagrams?
  2. 2. In the longest-consecutive code, why does if n - 1 in numbers decide to continue and skip n?
  3. 3. Which statements about the two keys for grouping anagrams are true? Pick all that apply.

    Pick every answer that is true.

  4. 4. Which statements about a set in the consecutive-run code are true? Pick all that apply.

    Pick every answer that is true.

  5. 5. What does this program print? ``python from collections import defaultdict words = ['tab', 'bat', 'cat', 'act'] groups = defaultdict(list) for w in words: groups[''.join(sorted(w))].append(w) print(dict(groups)) ``

5 question(s) left on this page.