PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates algorithmic problem-solving for interval manipulation and stateful data-structure design for maintaining and ordering agent averages, probing skills in sorting/merging, incremental updates, complexity analysis, and deterministic tie-breaking within the Coding & Algorithms domain.

  • medium
  • Atlassian
  • Coding & Algorithms
  • Software Engineer

Merge intervals and design rating APIs

Company: Atlassian

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

### Problem 1: Merge overlapping intervals You are given a list of closed intervals `intervals`, where `intervals[i] = [start_i, end_i]` and `start_i <= end_i`. **Task:** Merge all overlapping intervals and return a new list of non-overlapping intervals that cover the same ranges. **Input:** - `intervals`: an array/list of `[start, end]` pairs (not necessarily sorted) **Output:** - A list of merged, non-overlapping intervals (order can be by increasing start) **Follow-up:** - Support inserting one additional interval `newInterval` into the existing set and return the merged result efficiently. --- ### Problem 2: Implement agent-rating APIs with ordering by average Design and implement a data structure that supports the following APIs for rating “agents” by name. - `rateAgent(name, score)`: record a new rating for the agent `name`. - `name` is a string identifier. - `score` is an integer in `[1, 5]`. - `getTopAgents()`: return a list of agent names sorted by their **current average score** in **descending** order. **Details / requirements:** - Each agent can receive many ratings over time. - The average for an agent is computed over all ratings recorded so far for that agent. - `getTopAgents()` may be called many times; aim for an efficient approach across many operations. - Define a deterministic tie-breaker for equal averages (e.g., by name ascending). **Constraints (assume typical interview scale):** - Up to ~`10^5` total API calls. - Many repeated `getTopAgents()` calls should not require excessive recomputation each time.

Quick Answer: This question evaluates algorithmic problem-solving for interval manipulation and stateful data-structure design for maintaining and ordering agent averages, probing skills in sorting/merging, incremental updates, complexity analysis, and deterministic tie-breaking within the Coding & Algorithms domain.

Merge Overlapping Intervals

Merge closed intervals and optionally insert one new interval before merging.

Constraints

  • Each interval has start <= end

Examples

Input: ([[1, 3], [2, 6], [8, 10], [15, 18]], None)

Expected Output: [[1, 6], [8, 10], [15, 18]]

Explanation: Overlapping intervals are coalesced.

Input: ([[1, 2], [3, 4]], [2, 3])

Expected Output: [[1, 4]]

Explanation: Touching closed intervals merge.

Input: ([], [5, 7])

Expected Output: [[5, 7]]

Explanation: Insert into empty set.

Input: ([[5, 5], [1, 2]], None)

Expected Output: [[1, 2], [5, 5]]

Explanation: Unsorted input.

Hints

  1. Sort by start, then extend the last merged interval when ranges overlap.

Agent Ratings Ordered by Average

Process rate/top operations and return agent names sorted by descending average rating with name as the tie-breaker.

Constraints

  • Scores are integers in [1, 5]

Examples

Input: ((('rate', 'alice', 5), ('rate', 'bob', 4), ('top',), ('rate', 'bob', 5), ('top',)),)

Expected Output: [['alice', 'bob'], ['alice', 'bob']]

Explanation: Top queries reflect updated averages.

Input: ((('top',),),)

Expected Output: [[]]

Explanation: No agents yet.

Input: ((('rate', 'zoe', 4), ('rate', 'amy', 4), ('top',)),)

Expected Output: [['amy', 'zoe']]

Explanation: Ties sort by name.

Hints

  1. Keep running sum/count per agent and sort only when a top query observes dirty data.
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
  • 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)
  • Filter Invalid Data Events - Atlassian (easy)