Atlassian Coding Interview: Closest Common Group

Based on a candidate's reported Atlassian interview

The interviewer opens

Hi, and thanks for joining. Welcome to your interview for the Senior Software Engineer P50 role at Atlassian. We'll work through one coding problem together, and I'd like you to think out loud as you code. If you need to step out or take a break, you can pause the interview any time with the Pause button at the top right.

The problem is about finding the closest group two people share in a company's employee directory, which is the kind of hierarchy lookup a directory like Atlassian's has to answer. It's in the Problem tab on the right, so please read it through and ask me anything before you start.

The problem

Atlassian's employee directory arranges groups in a single hierarchy. Find the closest group that two employees share.

  • groups: list of {name, parent}. Exactly one root group has parent null. Every other parent names an existing group.
  • members: list of {employee, group}. Each employee belongs to exactly one group.
  • first, second: two different employee names, both in members.

A group contains an employee if the employee is in that group or in any group beneath it. Return the name of the deepest group (farthest from the root) that contains both employees. This can be one of their own groups.

Example: groups Atlassian (root), Engineering→Atlassian, Jira→Engineering, Confluence→Engineering, Sales→Atlassian; members alice:Jira, bob:Confluence, carol:Engineering, dan:Sales, erin:Jira; first="alice", second="bob" → "Engineering"

Up to 10^4 groups, hierarchy depth up to 10^4, 10^4 employees.