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?- A. [('s', 4)]
- B. [('i', 3)]
- C. [('i', 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
- Problem: What does the following print? python print(round(1.23456, 2), round(-2.5)) What is printed?
- Problem: What does the following print? python print(max([], default=-1), sum([]), divmod(-7, 3))
- Problem: What does the following print? python print(2 -1, 7 % -3)
- Problem: What does the following print? python print(sorted([3, 1, 2], key=lambda x: -x)[0]) What is printed?
- Problem: Starting from 3, you may apply two operations: "+1" or "×2". What is the minimum number of operations needed to reach exactly 50?
- Problem: A knight starts at square (0,0) on an infinite chessboard. What is the minimum number of knight moves needed to reach square (4,5)?