Intercom - Product Engineer - II Experience (Dublin)

intercom logo
intercom
Product Engineer - IIDublin
June 25, 20255 reads

Summary

This post details a coding interview problem from Intercom where I was tasked with designing and implementing an AssignmentSystem to distribute customer conversations among support agents efficiently, considering individual limits and load balancing rules.

Full Experience

In this exercise, you'll build a system to assign conversations to customer support agents.

Task

Implement an AssignmentSystem class that has the following API:

  • Initializes with a list of available agents.
  • set_limit(agent_name, limit)
    • Sets the conversation limit for a specific agent.
  • assign(conversation_id)
    • Assigns a conversation to the next available agent.
  • preview_assignments(count)
    • Returns a list of agents who would be assigned conversations next.

Requirements

  • When assigning conversations, balance load evenly:
    • Assign new conversations to the agent with the fewest conversations
    • If there are ties, pick the agent who's been waiting the longest since their last assignment
  • Each agent has a maximum conversation limit (default is 2)

Example:

agents = ["Alice", "Bob", "Charlie"]
system = AssignmentSystem(agents)

system.set_limit("Bob", 4)
system.set_limit("Charlie", 3)

I want to know who will receive next 4 conversations
system.preview_assignments(4)
Output: ["Alice", "Bob", "Charlie", "Alice"]

Make some assignments
system.assign(101) # Assigns to Alice
system.assign(102) # Assigns to Bob
system.assign(103) # Assigns to Charlie
system.assign(104) # Assigns to Alice

I want to know who will receive next 5 conversations
system.preview_assignments(5)
['Bob', 'Charlie', 'Bob', 'Charlie', 'Bob']

Interview Questions (1)

Q1
Conversation Assignment System
Data Structures & AlgorithmsMedium

In this exercise, you'll build a system to assign conversations to customer support agents.

Task

Implement an AssignmentSystem class that has the following API:

  • Initializes with a list of available agents.
  • set_limit(agent_name, limit)
    • Sets the conversation limit for a specific agent.
  • assign(conversation_id)
    • Assigns a conversation to the next available agent.
  • preview_assignments(count)
    • Returns a list of agents who would be assigned conversations next.

Requirements

  • When assigning conversations, balance load evenly:
    • Assign new conversations to the agent with the fewest conversations
    • If there are ties, pick the agent who's been waiting the longest since their last assignment
  • Each agent has a maximum conversation limit (default is 2)

Example:

agents = ["Alice", "Bob", "Charlie"]
system = AssignmentSystem(agents)

system.set_limit("Bob", 4)
system.set_limit("Charlie", 3)

I want to know who will receive next 4 conversations
system.preview_assignments(4)
Output: ["Alice", "Bob", "Charlie", "Alice"]

Make some assignments
system.assign(101) # Assigns to Alice
system.assign(102) # Assigns to Bob
system.assign(103) # Assigns to Charlie
system.assign(104) # Assigns to Alice

I want to know who will receive next 5 conversations
system.preview_assignments(5)
['Bob', 'Charlie', 'Bob', 'Charlie', 'Bob']
Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!