# Missing Ranges & One Edit Distance

#### Watch someone solve the missing ranges & one edit distance problem in an interview with a FAANG engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

### Interview Summary

**Problem type**  
Missing Ranges & One Edit Distance

**Interview question**  
The first problem asks the candidate to return the shortest sorted list of ranges that cover all missing numbers within a given inclusive range [lower, upper], given a sorted unique integer array. The second problem asks whether two strings are exactly one edit distance apart, where a single edit is defined as an insertion, deletion, or replacement of one character in the source string.

### Interview Feedback

**Feedback about Rocket Centaur (the interviewee)**  
**Advance this person to the next round?**  
No

**How were their technical skills?**  
2/4

**How was their problem solving ability?**  
2/4

**What about their communication ability?**  
3/4

> **Communication:**  
> He was engaged throughout the interview and communicated his thought process clearly. He successfully solved the easy problem with an O(n) solution.  
>  
> **Areas for Improvement:**  
> He should focus on improving his coding speed and problem-solving efficiency. He attempted the medium-complexity question but was unable to complete it within the available time. For the One Edit Distance problem, he initially proposed a dynamic programming approach, which added unnecessary complexity to the solution.  
>  
> **Advice for Future Interviews:**  
> Focus on improving coding speed and quickly identifying the simplest optimal approach. Aim to complete easy questions within the first 20 minutes and medium-complexity questions within 20–30 minutes, leaving enough time to test the solution and discuss edge cases.

**Feedback about Verdant Goblin  (the interviewer)**  
**Would you want to work with this person?**  
Yes

**How excited would you be to work with them?**  
4/4

**How good were the questions?**  
4/4

**How helpful was your interviewer in guiding you to the solution(s)?**  
4/4

### Interview Transcript

**Rocket Centaur:** Hello.  
**Rocket Centaur:** Hello, how are you? Hey, I'm good. How are you?  
**Rocket Centaur:** I'm doing okay. I hope you're having a good day so far.  
**Rocket Centaur:** Yeah, so far so good. Thanks for asking. Um, so this is a data structures algorithm coding interview, right?  
**Rocket Centaur:** That's correct.  
**Rocket Centaur:** All right, uh, we can get started. Uh, so what is your language of choice?  
**Rocket Centaur:** I would pick Python. I would probably choose that here. Yes, I would go with Python 3. Yes.  
**Rocket Centaur:** Okay. All right. Um, so are there any specific companies you are targeting for so that we can, uh, change our coding?  
**Rocket Centaur:** Yeah, nothing, nothing specifically. I'm just doing this as to— but it's been a while that I've done some coding exercise. So it's been like more than a couple of years. So yeah, just, just getting prepared for that.  
**Rocket Centaur:** Okay, let's start with the brief introduction. Normally I provide feedback on the introduction as well. So why don't you start introducing so that we can get started?  
**Rocket Centaur:** Sure, sure. I have around like 16, 17+ years of experience. I started working in like 2010, '11. Initially was a Java developer, backend Java developer, and A couple of years back, and in 2023, that's where I moved to ML AI space. So since then, I was an ML engineer, then I got into AI agentic automation. Yeah, that's, that's a whole thing about my, my tenure. Recently, I've been, you know, doing lots of automations on agentic with LangGraph and LangChain. Um, yeah, that's, that's in precise about me.  
**Rocket Centaur:** Okay, all right, sounds good. Uh, so in this interview I'll be asking 2 questions. Uh, one is like, you see, [REDACTED] Easy and [REDACTED] Medium. Uh, so if you solve those 2 questions, I can go, uh, go with one more question as well. Makes sense?  
**Rocket Centaur:** Sure, sure, perfect. All right, um, after I completed Sorry, no, no, no, I said that I would, I would try to complete it. I don't know how far I can do, but yeah, yeah.  
**Rocket Centaur:** All right, so should I paste the question here?  
**Rocket Centaur:** Yeah, yeah, that should be fine.  
**Rocket Centaur:** I don't know what is a comment in Python.  
**Rocket Centaur:** Is it—  
**Rocket Centaur:** so you see me, right?  
**Rocket Centaur:** Yes, I see the example. Yes, I see the example. Oh, I, I think, right, probably I think you pasted in the wrong window. I think that should be put in the, in the file where—  
**Rocket Centaur:** Oh yeah, on the left side.  
**Rocket Centaur:** Yes, yes, yes.  
**Rocket Centaur:** So I'll just put like this, that way it will be easy for you. OK. I'll remove you. Oh, I can't remove. OK, you can, you can go ahead and read the question.  
**Rocket Centaur:** Array numbers, all elements are within the inclusive range. So before that, just, um, okay, I just have issue with all this red line and, and yellow line. I'm just getting like, I would see what is the, um, uh, one line to comment, uh, to all these things, that would be helpful.  
**Rocket Centaur:** Uh, well, I, I'm— I think you will be writing code on the right side, right? I'm removing those, uh, lines everything.  
**Rocket Centaur:** Oh no, I, I would be— no, so I— that is the execution layout. Like if I run, you would see, uh, so it would be still on the left-hand side, I guess.  
**Rocket Centaur:** Okay, so, uh, what is the, uh, Python, uh, comment, blog comment?  
**Rocket Centaur:** I honestly do not know. I forgot. I always use the shortcut.  
**Rocket Centaur:** I think it's a Facebook star or something.  
**Rocket Centaur:** Oh yes, I think you're right. There was something like that. Let me Google it quickly.  
**Rocket Centaur:** I think it says hash. OK, OK, 3 double quotes.  
**Rocket Centaur:** Yes, right.  
**Rocket Centaur:** OK, where is the double quote?  
**Rocket Centaur:** I use this shortcut on a daily basis, but I honestly could not remember when you asked it.  
**Rocket Centaur:** Yeah, I know.  
**Rocket Centaur:** Yeah. OK, OK, so. OK, perfect. So let me go through this. You are given an inclusive range, lower and upper, and a sorted unique integer array numbers where all elements are within the inclusive range. OK, and number X is considered missing. If X is in the range and X is not in numbers, return the shortest sorted list of ranges that exactly covers all the missing numbers. That is, no element of nums is included in any of the ranges and each missing number is covered by one of the groups. So here, 0 and 99, lower and upper. The nums is 0, 1, 3. 50 and 75. Uh, so the output is 2 and 2. Uh, the range, uh, the ranges are 2 and 2. Uh, so 0, 1, 2, 2 is actually, um, missing. And then from 4 to 49. Oh, I see. So the starting and ending missing and then 4 to 49, 51 to 74, and 76 to 99. And these are all— so they're written as a list of lists, if I get that correctly.  
**Rocket Centaur:** Mm-hmm.  
**Rocket Centaur:** Perfect. OK. And there are other inputs for -1. Nothing has to be included. I see. I think I overall I got what needs to be done. Let me see if I have covered all the, all the scenarios. If I have— so this is something that we need to handle where there's, there's no inputs at all. On the other hand, if I get lower and upper, and then if the list is empty, then I would have to give lower and upper, right? That should be one of the scenarios if I understand that correctly.  
**Rocket Centaur:** No, if the nums is empty and if there is a lower and upper there, probably you should return -1 or the empty output, or empty output.  
**Rocket Centaur:** Oh, the empty output. Okay, so only if the number exists, then we got to give the list, or else I have to return -1.  
**Rocket Centaur:** Or yeah, yeah, so sorry, I'll retract a little bit back. Like, if you're asking the numbers itself is empty, but there is a lower and upper bound, then yes, yes, the output would be the lower, top, upper bound, right?  
**Rocket Centaur:** Got it. Perfect. Yeah, then I think my understanding is correct. So let me write a couple of scenarios here. So if it is empty and if there is an Lower and upper. I think I got that. Would we ever have a scenario that lower one— like between lower and upper one is -1? And okay, so I think I have the constraint here. So the constraint is -109 to 109. So it it could be in the negative numbers too then, right?  
**Rocket Centaur:** Mm-hmm.  
**Rocket Centaur:** I see. Um, so here it means that, um, between, uh, 2 numbers. So if it is between 2 numbers, actually it do not exist anything. Uh, so, uh, that's the reason we are returning the empty output. Um, on the other hand, I, I would— okay, I think I am getting the point. So the length could be of 0 to 100. All the values of the numbers are unique. Okay, I think I got a complete picture of it. So probably we have to run a loop from lower to upper, and then— so from— it should actually start with lower, right? So because the condition already says it is between lower and upper. And if starting from the lower— so do I— no, I probably don't have to do that check. I can probably start with the first variable.  
**Rocket Centaur:** Right.  
**Rocket Centaur:** And if the list itself is empty, right, I can— okay, there are actually a couple of edge cases, but let me start with building the core algorithm and then we would cover the edge cases.  
**Rocket Centaur:** Mm-hmm.  
**Rocket Centaur:** Okay, so what I think I should do is I would start with this, right, the first variable, and then I would keep— like, I would, I would probably run a loop and see that if if the variable exists in the— meaning, so—  
**Rocket Centaur:** Are you writing something?  
**Rocket Centaur:** I would— oh, no, no, no. I'm just thinking. So I would actually have something like a previous, right? Prev. So my prev would be nums of 0.  
**Rocket Centaur:** Right.  
**Rocket Centaur:** And then probably I would start with 1 and I would, you know, constantly update prev after all the single loop, right? And then I would see if prev plus 1 is equal to this. So I do that. So then I have a condition. If it is If it is same, I do not have anything to do. If it is not same, I would keep incrementing it the moment I find— So I probably do not increment it, right? Like, I would probably have start and end. And I would leave the start as it is. And end, I keep updating it the moment, like, you know, I would find a variable in the list Then I would update the list, and then I would add it to the output, returning output. So I would keep doing that until I find— go to the end of the list. So that would be my core algorithm.  
**Rocket Centaur:** Okay.  
**Rocket Centaur:** Do you want me to write some sort of a template to get a sense, or you're good with what I communicated?  
**Rocket Centaur:** I think what, what you communicated, you will run a loop right between, between lower to upper. Is that what you're saying?  
**Rocket Centaur:** Like, so I would do run a for loop for the nums. So something like, yes, so for i in range of 1 to the end, right? That is length of num. And then I already, you know, have this added. Now I would see if prev is equal to nums plus 1— sorry, i, right? So if it is same, I would have a logic. And if it is not, I would have a logic.
