# Merge Intervals — coding interview question | Aced

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/1602/merge-intervals
Source observed: 2026-11-04T22:21:38.255Z
Last checked: 2026-11-04T22:21:38.255+00:00
Indexed: 2026-11-05T19:44:22.582+00:00

---

# Merge Intervals

**Difficulty:** Medium  
**Category:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms&filterBy=codeEditor&src=nav)  
**Reported last asked:** 2 months ago  
**Interview reports:** 20 interviews  
**Saved by:** 127 users  
**Community:** 68

We are Aced, formerly Exponent, and this page provides a coding-interview practice question about merging overlapping numeric intervals. The **Question** tab is selected; the **Solution** and **Mock Interview** tabs are locked, and an editor is available for running code after sign-up.

## Problem

An interval represents a range of values on a number line. For example, `[1,3]` represents every number from 1 through 3, inclusive. Given a collection of intervals, merge all overlapping intervals.

For `[1,3]`, `[2,6]`, `[8,10]`, and `[15,18]`, the first two intervals overlap and become `[1,6]`.

## Examples

```text
intervals = [[1,3], [2,6], [8,10], [15,18]]
output: [[1,6], [8,10], [15,18]]

intervals = [[1,4], [4,5]]
output: [[1,5]]

intervals = [[1,4], [2,3]]
output: [[1,4]]

intervals = [[1,2], [3,4], [5,6], [7,8]]
output: [[1,2], [3,4], [5,6], [7,8]]
```

## Interview metadata

The page groups this question under the following reported roles and companies:

- Roles: [Software Engineer](https://www.aced.io/questions?role=swe) (10), [Data Engineer](https://www.aced.io/questions?role=data-engineer) (3), [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer) (2), AI Engineer, Data Analyst, Management Consultant, and Mobile Engineer.
- Companies: [Meta](https://www.aced.io/questions?company=meta-facebook) (3), [JP Morgan Chase](https://www.aced.io/questions?company=jp-morgan-chase) (2), Nooks, Micro1, Bloomberg, Visa, Google, Amazon, Intuit, Oracle, LinkedIn, Salesforce, IBM, TikTok, Nvidia, Walmart Labs, and State Bank Of India.

## Interview experiences

Seven shared interview experiences accompany the question. These are individual reports, not results from our own interview process:

1. [Nooks — Software Engineer, Entry Level / L3](https://www.aced.io/experiences/nooks-software-engineer-interview-51a30e) — 2 months ago: “Remeber to speak up about what you are doing while solving the technical questions. Besides that it's not too bad.”
2. [Micro1 — Software Engineer, Entry Level / L3](https://www.aced.io/experiences/micro1-software-engineer-interview-7e45a3) — 3 months ago: “The coding question was easy but the questions about debugging were very hard. Had to have production level knowledge to answer those.”
3. [JP Morgan Chase — Software Engineer](https://www.aced.io/experiences/jp-morgan-chase-software-engineer-interview-4f12f0) — 3 months ago: “the technical round was that difficult but the behavioral round would need more focus on, especially the star methods”
4. [JP Morgan Chase — AI Engineer, Mid Level / L4](https://www.aced.io/experiences/jp-morgan-chase-ai-engineer-interview-3ef69d) — 4 months ago: “Recruiter contacted, set up 1st round phone screen with a senior engineer. 45 mins with 20 mins on past projects etc diving in detial before talking about AI/LLM concepts. Was easy 2nd round was 2 stanmdard leetcode coding qns 45 mins with 1st 15 mins on behvaioural so only 30 mins to solve both qns but was quite doable. Walked though the brute force naive approach before moving on to the optimal solution and O(nlogn) etc tiome complexity.”
5. [Bloomberg — Software Engineer](https://www.aced.io/experiences/bloomberg-software-engineer-interview-1f5d83) — 8 months ago: “The process was recruiter call followed by technical screen. If one is successful, then virtual onsite - coding and system design/project depending on the team matched with. Recruiters are helpful and explain the process well and send the required material for preparation.”
6. [Meta — Machine Learning Engineer, Senior / L5](https://www.aced.io/experiences/meta-facebook-senior-machine-learning-engineer-interview-349bcb) — 2 years ago: “One of the technical rounds was ridiculous, a LC hard (LC3548) ML Systems Design was pretty standard - design a recommender system Behavioral round fairly standard”
7. [Amazon — Data Engineer, Intern](https://www.aced.io/experiences/amazon-data-engineer-intern-interview-d0041d) — 2 years ago: “Interviewer were all really nice. Technical portion requires to be thorough in explaining thought process”

## Related courses

### [AI Engineering Interview Prep](https://www.aced.io/courses/ai-engineering)

![AI Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/25mhKSvDOiCwC89lDj89Ah/9a5fbfacc8d93f05c238ab55baa4e5e5/fde.png?w=800&h=800&fm=webp&q=75)

We help prepare candidates for AI engineering interviews at companies such as Google, Anthropic, Meta, and OpenAI through frameworks, example questions, mock interviews with senior engineers, system design, AI/ML concepts, AI-assisted coding, and behavioral-round practice.

### [Generative AI Interviews](https://www.aced.io/courses/gen-ai-interviews)

![Generative AI Interviews](https://images.ctfassets.net/x78yjrjc11pq/BLBU7an1PjT0Mt2ZzAfDa/60e119c8bff0cfb8281dcb497177f6e3/AdobeStock_1510292201-min.jpeg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for interviews at AI-first and AI-powered companies. The course covers explaining how generative AI works, where it fails, and how to use it responsibly, along with AI products in production, LLMs, retrieval-augmented generation (RAG) systems, and real-world deployment.

## Code editor

The page includes a Python editor with **Editor** and **Share** views, plus **Output**, **Test Results**, and **Console** panels. [Sign up to run code](https://www.aced.io/signup?src=lesson).

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1602%2Fmerge-intervals&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1602%2Fmerge-intervals). Opening a form does not execute a tool.