Data Structures & AlgorithmsVery hardProduct Company SDE · Python round

Problem: What does the following print?

Problem: What does the following print?
from collections import Counter
print(Counter('mississippi').most_common(1))
What is printed?
  1. A. [('s', 4)]
  2. B. [('i', 3)]
  3. C. [('i', 4)]
  4. D. [('m', 1)]

Correct answer: C. [('i', 4)]

i and s both occur 4 times, and most_common keeps the first-seen letter (i) among ties.

More Coding Interview Problems questions

Exams that ask this topic