← Atlassian Interview Insights

Atlassian·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Atlassian SWE interview with a classic interval merging problem. The follow-up variants were the real test and I wasn't fully prepared for them.

Questions Asked (3)

Q1

Given an array of intervals, merge all overlapping ones and return the resulting non-overlapping intervals.

Algorithms & Data Structures
Author's notes

Sort by start time then sweep through, merging as you go.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Sort the intervals by their start times, then iterate through them while maintaining a 'current' merged interval, extending it whenever the next interval overlaps. This greedy approach ensures a single linear pass after sorting, yielding an O(n log n) overall solution dominated by the sort step.

Pro tip: Proactively mention edge cases like an empty input array, a single interval, or intervals that are only touching (e.g., [1,2] and [2,3]) and clarify with your interviewer whether touching intervals should be merged — this signals production-level thinking that Meta values.

1. Clarify & Define Constraints

Confirm input format (e.g., list of [start, end] pairs), whether intervals can be unsorted, and edge cases like empty arrays or touching intervals. Ask if in-place modification is preferred or a new list is acceptable.

2. Sort Intervals by Start Time

Sort the array of intervals based on the start value of each interval. This guarantees that any overlapping interval with the current one can only appear immediately after it in the sorted order.

3. Iterate and Merge Greedily

Initialize a result list with the first interval, then for each subsequent interval check if its start is less than or equal to the current interval's end. If so, extend the end to the maximum of both ends; otherwise, push the current interval to results and start a new one.

4. Handle Final Interval

After the loop, ensure the last active interval is appended to the result list, as it won't be pushed inside the loop iteration.

5. Analyze Complexity & Test

State the time complexity as O(n log n) due to sorting and O(n) space for the output. Walk through 2-3 test cases including normal overlap, no overlap, and fully contained intervals to validate correctness.

Key Points to Mention

  • Sorting by start time as the foundational step that enables a single greedy pass
  • Overlap condition: next interval's start <= current interval's end (using ≤ vs < depending on touching-interval definition)
  • Merging by taking the maximum of the two end values to handle fully contained intervals (e.g., [1,10] swallowing [2,5])
  • Time complexity O(n log n) and space complexity O(n) for the output array
  • Edge cases: empty input, single interval, all intervals overlapping into one, no overlaps at all
  • In-place vs. new-list trade-offs and whether the original array should be mutated

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How would you handle a streaming version of this problem, where intervals arrive one at a time and you need to support queries on the current merged set?

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

This is where things got uncomfortable.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what types of queries (e.g., point stabbing, range overlap, total coverage), expected throughput, and whether intervals can be deleted or updated. Then propose a data structure that maintains the merged set incrementally, such as a balanced BST of disjoint intervals, and discuss trade-offs between update and query costs. Finally, outline how you would handle concurrency and persistence if needed.

Pro tip: Mention that you would keep the merged set as a sorted list of disjoint intervals and use binary search for queries, but also consider a segment tree or interval tree if queries are more complex. Showing awareness of real-world constraints like memory and latency will impress.

1. Clarify requirements

Ask about query types, update frequency, latency requirements, and whether intervals can be removed or modified. This ensures you design the right solution.

2. Choose data structure

Propose maintaining a dynamic set of disjoint intervals, e.g., using a balanced BST (like a red-black tree) keyed by start point, or a skip list for simpler concurrency.

3. Handle insertion and merging

Describe how to insert a new interval: find overlapping intervals, merge them, and update the set. Discuss time complexity (O(log n + k) where k is number of overlaps).

4. Support queries

Explain how to answer queries efficiently, e.g., point stabbing via binary search, range overlap by finding intervals intersecting a query range.

5. Discuss scalability and trade-offs

Address concurrency (locking, lock-free), persistence, and alternative structures (segment trees, interval trees) with their pros and cons.

Key Points to Mention

  • Use a balanced BST or skip list to store disjoint intervals sorted by start.
  • Insertion requires merging overlapping intervals, which can be done by finding predecessors/successors.
  • Queries like point stabbing can be answered in O(log n) via binary search.
  • Trade-offs: balanced BST gives O(log n) updates and queries, but concurrency can be tricky; segment trees are better for static or offline scenarios.
  • Consider memory overhead and whether intervals can be deleted (requires handling splits).
  • Mention real-world considerations: thread safety, persistence, and handling out-of-order arrivals.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

If you already have a fully merged list of intervals, how do you efficiently insert a new interval into it?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Binary search to find where the new interval fits, then walk left and right to absorb any overlaps.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying that the input list is sorted and non-overlapping, then describe a linear scan approach that adds all intervals ending before the new interval, merges all overlapping intervals, and finally adds the remaining intervals. Emphasize that this achieves O(n) time and O(n) space, which is optimal since the output may require copying all intervals.

Pro tip: Mention that if the list is stored in a data structure allowing in-place modification (like an array with extra capacity), you can merge in O(k) extra space where k is the number of overlapping intervals, but in the worst case it's still O(n). Also, note that binary search can find the insertion point in O(log n) but merging still requires O(n) due to shifting elements.

1. Clarify assumptions and constraints

Confirm that the existing list is sorted by start time and contains no overlapping intervals. Ask about the expected size of the list and whether in-place modification is allowed.

2. Outline the linear scan approach

Explain that you will iterate through the intervals, adding all intervals that end before the new interval starts, then merge all intervals that overlap with the new interval, and finally add the remaining intervals.

3. Detail the merging logic

Describe how to update the new interval's start and end when overlapping: new_start = min(new_start, current_start), new_end = max(new_end, current_end). Continue until an interval starts after the new interval ends.

4. Analyze complexity and trade-offs

State that the time complexity is O(n) because each interval is visited once, and space complexity is O(n) for the output list. Mention that binary search for the insertion point doesn't improve overall complexity due to shifting/merging.

5. Discuss edge cases and optimizations

Cover edge cases: new interval before all, after all, overlapping multiple, or contained within one. Mention that if the list is empty, just return the new interval. If in-place is allowed and there's extra capacity, you can merge without allocating a new list.

Key Points to Mention

  • The input list is sorted and non-overlapping, which simplifies merging.
  • Linear scan is optimal because you may need to merge with many intervals, and the output size can be O(n).
  • Binary search can find the insertion point in O(log n) but merging still requires O(n) time due to shifting elements.
  • Space complexity is O(n) for the output, but can be O(1) extra if modifying in-place with sufficient capacity.
  • Edge cases: new interval before all, after all, overlapping multiple, or contained within one.
  • The algorithm can be implemented in a single pass without extra data structures beyond the output list.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.