← back to unit
Medium
# power tools medium
The Most Common Bead, Turbo Mode
Third time's the charm: you found the most common bead with nested loops, then with sorting. The dict way is the champion's way. 📿⚡
You get the bead nums. Print the most common value; on a tie, the smallest such value.
Example:
Input: nums = [4, 1, 4, 2, 1, 4]
Output: 4
Tallying gives 4→3, 1→2, 2→1 — 4 appears the most.
💡 need a hint?
pt-most-common-turbo.py🔒 given lines are locked — write your code in between
loading...