Design a voting counter for restaurants
Company: Ziprecruiter
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates familiarity with hash-table–based counting, efficient update and lookup operations, handling of ties with a deterministic tie-break rule, and reasoning about edge cases like unseen names or no votes.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([['getWinner'], ['vote','Sushi'], ['vote','Taco'], ['vote','Taco'], ['getWinner'], ['getCount','Sushi']],)
Expected Output: [None, None, None, None, 'Taco', 1]
Explanation: Votes and count.
Input: ([['vote','B'], ['vote','A'], ['getWinner']],)
Expected Output: [None, None, 'A']
Explanation: Tie breaks lexicographically.
Input: ([['getCount','None']],)
Expected Output: [0]
Explanation: Unseen count.
Hints
- Choose a representation that makes the requested operation direct.
- Handle empty inputs and boundary cases first.