Skip to main content
All Questions

Merge Intervals

Medium

Merge Intervals. An interval is a representation of a range of values along a number line. For example, [1,3] represents all numbers between 1 and 3, inclusive. Given a collection of intervals, the task is to merge all overlapping intervals.

For example, consider the intervals [1,3],[2,6],[8,10],[15,18]. The function should return merged intervals where overlapping intervals are combined. In this case, intervals [1,3] and [2,6] overlap, so they should be merged into [1,6].

Examples

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 experiences

6 shared
M
Micro1 · a month ago
"The coding question was easy but the questions about debugging were very hard. Had to have production level knowledge to answer those."
Software Engineer · Entry Level / L3
JP Morgan Chase · a month ago
"the technical round was that difficult but the behavioral round would need more focus on, especially the star methods"
Software Engineer
JP Morgan Chase · 2 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."
AI Engineer · Mid Level / L4
Bloomberg · 6 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."
Software Engineer
Meta · a year 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"
Machine Learning Engineer · Senior / L5
Amazon · 2 years ago
"Interviewer were all really nice. Technical portion requires to be thorough in explaining thought process"
Data Engineer · Intern

Related courses

Course

AI Engineering Interview Prep

Ace the AI engineering interview at top companies like Google, Anthropic, Meta, and OpenAI. Learn from detailed frameworks, example questions, and mock interviews with senior engineers. Practice system design, AI/ML concepts, AI-assisted coding, and behavioral rounds.

Course

Generative AI Interviews

Ace your interviews at AI-first and AI-powered companies. Learn to explain how Gen AI really works, where it fails, and how to use it responsibly. Understand how top tech companies build and deploy AI products and how generative AI works in production, from LLMs and RAG systems to real-world deployment.