PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Ziprecruiter

Design a voting counter for restaurants

Last updated: Mar 29, 2026

Quick Overview

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.

  • medium
  • Ziprecruiter
  • Coding & Algorithms
  • Software Engineer

Design a voting counter for restaurants

Company: Ziprecruiter

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are building an in-memory voting component for a lunch poll. ## Task Design and implement a hash-table–backed data structure that supports collecting votes for restaurant names and reporting the most popular restaurant(s). ## Requirements - Each vote is a string `restaurantName`. - You must maintain vote counts as votes arrive. - Support these operations: 1. `vote(restaurantName)`: record one vote for the restaurant. 2. `getCount(restaurantName) -> int`: return the current vote count (0 if never seen). 3. `getWinner() -> string`: return the restaurant with the highest vote count. - If there is a tie, return the lexicographically smallest name (or clearly state and implement a deterministic tie-break rule). ## Constraints (assume) - Up to `N` total votes, where `N` can be large (e.g., 10^5–10^6). - Restaurant names can repeat and may include spaces. - Aim for near O(1) average time per `vote`/`getCount` using hashing. ## What to discuss - Data structures used and why. - Time and space complexity. - Edge cases: no votes yet, ties, unseen restaurant names.

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.

Related Interview Questions

  • Find Neighboring Records by Identifier - Ziprecruiter (easy)
  • Implement an in-memory storage with TTL and scans - Ziprecruiter (medium)
Ziprecruiter logo
Ziprecruiter
Feb 2, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0
Loading...

You are building an in-memory voting component for a lunch poll.

Task

Design and implement a hash-table–backed data structure that supports collecting votes for restaurant names and reporting the most popular restaurant(s).

Requirements

  • Each vote is a string restaurantName .
  • You must maintain vote counts as votes arrive.
  • Support these operations:
    1. vote(restaurantName) : record one vote for the restaurant.
    2. getCount(restaurantName) -> int : return the current vote count (0 if never seen).
    3. getWinner() -> string : return the restaurant with the highest vote count.
      • If there is a tie, return the lexicographically smallest name (or clearly state and implement a deterministic tie-break rule).

Constraints (assume)

  • Up to N total votes, where N can be large (e.g., 10^5–10^6).
  • Restaurant names can repeat and may include spaces.
  • Aim for near O(1) average time per vote / getCount using hashing.

What to discuss

  • Data structures used and why.
  • Time and space complexity.
  • Edge cases: no votes yet, ties, unseen restaurant names.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Ziprecruiter•More Software Engineer•Ziprecruiter Software Engineer•Ziprecruiter Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.