PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates the ability to design in-memory data structures and algorithms for recording and aggregating agent votes, including computing average ratings, sorting by aggregate score with tie-breaking, handling update semantics for repeated votes, and accounting for items with no votes.

  • medium
  • Atlassian
  • Coding & Algorithms
  • Software Engineer

Implement agent voting with average and sorting

Company: Atlassian

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Design an in-memory “agent voting” module that records ratings agents give to items (e.g., tickets/articles). Requirements: - Each vote is: `(agentId, itemId, rating)` where `rating` is an integer (e.g., 1–5). - Support computing the **average rating** for a given `itemId`. - Support returning items **sorted by average rating** (descending). Specify how ties are broken (e.g., by `itemId` ascending). Clarify behaviors: - If the same agent votes on the same item multiple times, should the latest vote replace the previous one? - What should be returned for items with no votes? Provide the core data structures and methods, and analyze time/space complexity.

Quick Answer: This question evaluates the ability to design in-memory data structures and algorithms for recording and aggregating agent votes, including computing average ratings, sorting by aggregate score with tie-breaking, handling update semantics for repeated votes, and accounting for items with no votes.

Record item ratings by agent, replacing repeat votes by the same agent, and return averages or sorted items.

Constraints

  • Ratings are integers

Examples

Input: ((('vote', 'a', 'x', 5), ('vote', 'b', 'x', 3), ('avg', 'x')),)

Expected Output: [4.0]

Explanation: Average from two agents.

Input: ((('vote', 'a', 'x', 5), ('vote', 'a', 'x', 1), ('avg', 'x')),)

Expected Output: [1.0]

Explanation: Latest vote replaces previous.

Input: ((('vote', 'a', 'x', 4), ('vote', 'a', 'y', 5), ('sorted',)),)

Expected Output: [[('y', 5.0), ('x', 4.0)]]

Explanation: Sorted by average descending then item.

Hints

  1. Maintain per-agent item votes plus per-item totals and voter counts.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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
  • AI Coding 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.

Related Coding Questions

  • Find a secret word using match feedback - Atlassian (hard)
  • Compute a moving average on a stream - Atlassian (hard)
  • Implement sliding-window rate limiter function - Atlassian (medium)
  • Implement sequential and parallel URL requests - Atlassian (medium)
  • Merge intervals and design rating APIs - Atlassian (medium)