Interview Transcript
Stealthy Elephant: Okay, so I'm going to ask you a question and depending on time, we'll go on to the next one and let's get started. Okay, so yeah, so first question I do want to ask is called longest consecutive sequence. Okay, I'm gonna write out the question. Copy it over. Okay, so if you see from line one to line 20. So given an unsorted array of integer nums, return the length of the longest consecutive element sequence. Okay, so for example, once we see that, I purposely removed the output because I want to make sure you understand the question. So do you mind going through the examples and letting me know what you think the answer is?
Factual Lightning: Yeah, so for me, when I'm looking at this, at it makes me think that it's going to be the longest sequence where it's strictly increasing. Okay, so for example, 100 and 200. Well, 100 would be itself four and 200 would be one, and then one and three would be another. So I guess two would be the longest.
Stealthy Elephant: Mm. Yes, Steve. Mm. So just to elaborate, because, so given on this order of Raymond nums, we want to return the length of the longest consecutive element sequence, right? So example would be when we see 104, 201, 3, 2, it is more so we see 1, 2, 3, 4. So that would be the longest consecutive elements for this input nums, for example, 1.
Factual Lightning: Oh, okay, so it's 1, 2, 3, 4 is here.
Stealthy Elephant: Okay. Correct, Correct.
Factual Lightning: Oh, okay. And consecutive, meaning it has to go up by one.
Stealthy Elephant: Yes, correct.
Factual Lightning: Okay, and is that, is that like a strict rule? So, for example, what about 1, 1, 2, 1, would that be incorrect?
Stealthy Elephant: These would be all unique, actually. It doesn't have to be unique. 1, 1, 2, 3, 4. That's fine. Okay.
Factual Lightning: Okay, got it. So I mean the. I mean, easy way to do it would be to sort, right? That would be an easy way to go about.
Stealthy Elephant: Mm.
Factual Lightning: I'm trying to think if there would be something simpler, I mean, something quicker than sorting. Like if we take multiple passes, potentially.
Stealthy Elephant: Well, Michael, before we head into the solution, do you mind going through the example 1, 2, 3, providing your output answer just. Oh, sure, yeah.
Factual Lightning: So for this one we see a 1, 3, 4.
Stealthy Elephant: Perfect.
Factual Lightning: Like we discussed. Let me see here. So there's a 0, a 1, a 2, a 3, a 4, a 5, 6, 7 and 8. So that's 9. But I'm guessing it has to be unique, so I wouldn't double count the zero.
Stealthy Elephant: Right, correct.
Factual Lightning: 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7. Okay, and then for this last 1, 0, 1, 2.
Stealthy Elephant: Perfect.
Factual Lightning: So it would be three.
Stealthy Elephant: Perfect.
Factual Lightning: Yeah. I just need the length though, so the output like 4. Good cash.
Stealthy Elephant: Good cash. And before I preface, I just want to let you know I've done about 40 plus interviews at last year, so I do interview for senior engineer and staff level roles. So if you see some points where I'm a little bit vague, it's most likely on purpose. So good cash on that. Sometimes people just go through the question and they just return outputs and just keep coding. Sometimes they don't read the question properly, then they miss the point where you have to return the length. Okay, good cash though.
Factual Lightning: Okay, so are you okay with me kind of thinking about the solution?
Stealthy Elephant: Perfect. Yes. Yes, I am.
Factual Lightning: Okay, like we said, sorting is easy, but I think if we use some space, we can come up with a way that's one pass. Like for example, let me use this one here. So let's say we have all of these in like a map where we have 104, 2 and then we're going through 1. Right. We're looking at 100 and then we iterate through. Is like, is 101 in map? If it is, we can increment our count. Right. And then I think we do that for all of them. So we start at 4, right. Is it in map? Obviously, because we're looking at it five, six, and then we stop when it's not.
Stealthy Elephant: And then.
Factual Lightning: At one we'll look at one, we'll see there's a two, there's a three and a four. That'll give us that. I'm trying to think of potential edge cases here. Oh, I think if we don't want to double count. Right. So like if we already. So let's say we're already at one, we already know that 1234 is in the map. There's no need to double count that because the lowest number will yield the highest count anyways. So that makes me think that once we see something in the map, do we remove it or. That's something I'm going to need to think about. Let me start getting some code down for this and then I'll try and trace what. I have to put pause there.
Stealthy Elephant: Why do you want to specifically use the hashmap in this situation? I see you were talking about counts of. Well, do you mind telling me a little bit more about your thought process behind that?
Factual Lightning: Yeah, so the, the thought process is like in, in the very simple way we can sort this. Right. And we just kind of count.
Stealthy Elephant: Yeah.
Factual Lightning: And kind of like a. Almost like a window or I mean, even within the window, we just count until we're more than one. That would give us N log N. My next thought was how can we. Is there a faster algorithm itself or can we leverage space potentially to be there some way? So the hashmap, it tells us all the numbers we have. So kind of like a, like a quick search, essentially.
Stealthy Elephant: Yes. Okay.
Factual Lightning: And since. Yeah, since we know we need to go consecutive, we can just loop plus.
Stealthy Elephant: One plus one plus one until. Yeah, that sounds like a right direction, but I do feel like there is. So let's just say you put the numbers in a hashtag, then what would you like to do with it? So.
Factual Lightning: If these are in the map. Right. Then we're going to go through each one of these and then kind of iterate. Can I show some code I think that will.
Stealthy Elephant: Yeah, yeah, of course. Yeah, of course. Let's see.
Factual Lightning: How do you spell that word? Sorry? Consecutive. Okay. It'll take Wants to return that. So let's say. I don't know if it's worth doing this, but just in case. So now create this hash map. We could just keep it a dual. And we'll go through each one of these.
Stealthy Elephant: Okay.
Factual Lightning: So now what idea is. Is I'm going to go through this again. And now we'll start with count is equal to 1. I'll have like a max. Just say longest, And then we'll do four. Well, we could keep it 0, just 4n pretty much. And just to be more explicit, we can do this. So now what I want to do is I'm going to increment this count by one, and the current number we're looking at by one. And so, like. So that's kind of the idea I have right now. And then we'll. So that's kind of the thought right now. So. But now I want to kind of put this through some.
Stealthy Elephant: Tests. Okay.
Factual Lightning: I guess this is something. I mean, in a typical interview. Can I just write a test for this and run it?
Stealthy Elephant: Yes. Usually in a typical interview, they have like a quarter pack. They have test cases. So I can provide you the cases. Just for the sake of time. I just want to quickly go over.
Factual Lightning: Yeah, yeah. I think it'd be worth it to kind of just trace my. Yes here. Okay, so let's say. Let me paste this. This here just so I have a reference. So I'm going through 100. Count is zero. Say cur. It goes through one. One iteration of the loop. Cur. I don't need this, but let's call it iteration. So this is in the map. So that results in count of 1, curr, 101. And then that is not in the map. So we would break out of here. August would update to one.
Stealthy Elephant: We would.
Factual Lightning: Which is correct. And then we would do the same for four. It would travel to pretty much have the same result as 100 because there's nothing above it. 200 would be the same. I think the one that's interesting to me is if we started at one, so. Count is now one. Curr becomes 2. That is in the map as well. Count becomes 2. Curve becomes 3. That is in the map as well. New count is three, Curve becomes four. That in the map as well. And then count is four. That's not in the map. And we'll break out and then set longer four. So that makes sense. Now if we were to go to.
Stealthy Elephant: Three.
Factual Lightning: Three would start pretty much here, here, and it would just do 3, 4, and then gallon count would just be 2. I guess what we could do is like if one optimization I could do is we can track our starting.
Stealthy Elephant: How would you try to do starting in this case?
Factual Lightning: Well, we can, We could kind of do this maybe. I'm trying to think if we just start from the next one and then delete that from the map. If that would work.
Stealthy Elephant: Question for you. Let's just say we look at a number. Correct. How do we know that this is the start of a sequence?
Factual Lightning: How do we know if that's the start of the sequence?
Stealthy Elephant: Yes.
Factual Lightning: Well, if. That is a good question. If the, if the number before it isn't in the map, we know it's the start of the sequence.
Stealthy Elephant: Perfect. And based on the information, then you can definitely make the code a little bit more efficient. Right.
Factual Lightning: Let's keep this. Now let me see if. Maybe before we loop if track of N minus 1. So if we're, if we're at 3, we won't even try. If we're at 2, we wouldn't. Now I want to make sure that's correct because I don't want it to like accidentally remove a valid option. But I think, I think it's fine because if, like, for example, if, if it was just 1 0, we know zeros in our map. So there's no like risk that we're going to miss something above one if it isn't even there because we would start at zero anyways eventually. So that past. I think that's okay is if I do something like this. Now the other question is a duplicate. Like if we've already. But maybe that's. We don't want to double count that. I mean, maybe. I don't know if it's worth it to keep. Maybe after we're done we could just remove it. I don't know if that's an optimization. Like, let's say there was another one here. If we were to remove one from the map by the time it got to it, this, it wouldn't even go here.
Stealthy Elephant: Yeah.
Factual Lightning: And that would be fine. Let me get some space here. Okay. That's the last thing I'm thinking now is do we want one more thing to remove a duplicate count? I think that, I think it'll be safe if we were to do that.
Stealthy Elephant: So you know how you said that you're worried about duplicates, Correct?
Factual Lightning: Yeah. So there's, there's two ways to go.
Stealthy Elephant: About this and any, any way can work. Right. So where this duplicate. So hash map is looking good, but maybe instead of iterating through. Iterating through your list, the input list. Maybe you can iterate through the hash map. That can also be idea. So therefore you're iterating instead of iterating to the list where there's duplicates. Yes. So that's a possible way. And then what's the. So this is the second way I want to challenge you on. Right. So the first way, yes, it works, but it may not be the cleanest. Right. What is something else we can use to kind of just make our lives easier? This is a similar method. Right. Something with. Along the lines with duplicates, there's another thing we can use that can make our lives way easier.
Factual Lightning: So like you said, one option is just instead of iterating through the list, we just iterate through our hash map and then do the same thing here. And then that would kind of remove the duplicate problem. And we can still do this as well. The previous element.
Stealthy Elephant: Yeah.
Factual Lightning: So you're saying there's another thing I can do as well?
Stealthy Elephant: Yes, yes. So I'll give you like maybe like few seconds to figure it out. If not, we can. It's okay. Your first, your first path works as well. So we can go with that. Is there anything we can use?
Factual Lightning: Let me, let me modify this to use the map and then I'll. Yeah, that sounds good if it comes to me. And then essentially the same.
Stealthy Elephant: Here.
Factual Lightning: Okay, let me just double check. Previous one is there. We can skip this one. Then we start at N and we iterate and then we track the longest we've seen and then we know we won't deal with duplicates because we're iterating through the map itself. Yeah, I'm a little stuck on the hint you were trying to give me on.
Stealthy Elephant: Yeah, it's not a big issue, but let's go with the hashmap solution. Let's go with this one. And then I'll tell you at the end, like how we can make it a little better. I think this is good enough though. So let's see, let's try any, any, any details and try running it and then we can go from there. Okay.
Factual Lightning: Oh, you already put it here.
Stealthy Elephant: Okay. Yes.
Factual Lightning: Oh, is this side 493. Okay.
Stealthy Elephant: Do you see the execution on the right side?
Factual Lightning: Yeah, I think it's on the right. Right. This 493. Yeah.
Stealthy Elephant: Okay. Okay, perfect. It looks good. Now what would be the time complexity for a solution?
Factual Lightning: So time complexity would just be 2n or just n. And then a space would be. Yeah, space would be n. Because we're tracking.
Stealthy Elephant: Yeah, sounds great. Sounds great.
Factual Lightning: So.
Stealthy Elephant: Yes. So quick feedback. So you did well. First question, I think, because I know for staff or seniors, they're always looking for the most cleanest, efficient solution, even if it works. So something sometimes people are nitpicky about is maybe instead of using the hash map, you can use a hash set. You can use a hash set and just iterate through hash set. So therefore you don't have to keep track of the keys and values where you can just create the hash set based on the input that you received. That's one thing, like a minor efficiency. And then number two is maybe instead of doing iftrack n minus one, you can do like a something like this along line 57. You can kind of just remove that and just put like this just for it. Like syntax wise, you have your other solution. Does work. Everything is good.
Factual Lightning: I'm just gonna put it back just.
Stealthy Elephant: In terms of like syntax wise, like specific coding paths. They want you to be a little bit more side. But other than that, this question was good. Any questions for this one?
Factual Lightning: No, I think it makes sense, I guess, on your comment on the hash set. Go doesn't have a set.
Stealthy Elephant: Oh, okay. Perfect. Perfect. Okay, so hashmap should be the best solution. Perfect, perfect. Now, anything else before we move on to the next question?
Factual Lightning: No, that makes sense. Thank you.
Stealthy Elephant: Perfect. All right, sounds good. Sounds good. Okay, second question. I'm going to remove this. Don't mind me. Maybe I'll just. Okay. Are you familiar with trees?
Factual Lightning: I'll give it my best shot.
Stealthy Elephant: Yeah. Okay, perfect. Don't worry. So I'm going to copy and paste this question and we can go through it. Okay. Okay, so given a binary tree root, return the level order traversal of it as a nested list where each sub list contains the values of nodes at a particular level in the tree from left to right. Okay, so if you see example 1, we have the tree, right? 1 is the root node, 2 is the left child node of 1, 3 is a right child node of 1, and then 4 or 5 are the child's nodes of 2, 6 and 7 are the child nodes of 3. So based on this, do you mind going through the examples and the corresponding answers?
Factual Lightning: Sure. I don't see any trees.
Stealthy Elephant: For example, line five to seven. Line five to seven.
Factual Lightning: Oh, yeah.
Stealthy Elephant: So this, this first row of five one is like a child node, and then line six is two and three child knows of one.
Factual Lightning: Right. Okay. And what was your question again?
Stealthy Elephant: Oh, do you mind going through the Each example and making sure that you understand the output.
Factual Lightning: Oh yeah. Okay, so level order traversal pretty much is kind of like you just go through the level. So root is only root is going to be by itself, pretty much go through the rows. If you could think of it as rows from left to right, each level. So one will be its own, and then from left to right it's 2 and 3 in its own list. And then 4 through 7 would be its own list.
Stealthy Elephant: Yep, perfect. Yep. Very straightforward. Now, how would you approach this solution?
Factual Lightning: Yeah, so the way I'm thinking about it is the way it's kind of speaking about levels makes me think of like a BFS type solution and which I'm using a queue. But I think the trick is going to be that I need a cap. Like when I'm iterating through the items in the queue, I need to cap it by the length first. So I make sure I'm only adding that level to the answer. Or else I would have to come up with my own struct that keeps track of level. And I don't think that would be worth it. That's kind of how I'm thinking about. So I'll start at the root that's going to be in the queue and it'll be the only one in that level. So add that as a list. I'll have to be building an array during my inner loop. And then I'll add left if there's a left, if I'll add right if there's a right, and then that type of thing. And then I'll just repeat that process until the queue is empty and I'll keep adding that list to the main result is what I'm thinking.
Stealthy Elephant: Yeah, it sounds like the right direction. Okay.
Factual Lightning: Let'S give it a go. And we'll take. Can. Should I assume I have a struct or should I assume it? Yeah. Okay. I'll just say. It doesn't need to be public.
Stealthy Elephant: Okay, perfect.
Factual Lightning: So let's do that. And then this will be a list of list of the values.
Stealthy Elephant: That's what it looks like. Okay.
Factual Lightning: So easy case. If the root is nil. Nothing. Now what we can do is.
Stealthy Elephant: Let.
Factual Lightning: Me set up the results array and then also the queue, which will be a queue of nodes and I can initialize it from the start.
Stealthy Elephant: Okay.
Factual Lightning: Make sure that looks fine to me. Okay. And now what I do here is I want to set up a current. Why is it Q keeps trying to correct that for me? Okay, So I want to set up a Current list that I'm looking at.
Stealthy Elephant: Which will be, I guess, to be.
Factual Lightning: More explicit.
Stealthy Elephant: Call it level.
Factual Lightning: And then we'll say N is the length of this queue, This level, essentially. So let me call this something else size. That way I can use N as.
Stealthy Elephant: This one. Okay.
Factual Lightning: So I'm going to get the first thing in the queue and then get rid of it. That makes sense.
Stealthy Elephant: And then.
Factual Lightning: All I have to do is add it, I believe, to our current level. And after we've added it. So let's say if this was the root, we would have a one. And then what we would need to do. There's still a couple more three things I need to do. Let me just add this. Once we're done iterating through a level, we add, change that to level.
Stealthy Elephant: Okay.
Factual Lightning: Now if n dot left doesn't need a nil, we can add it to the queue as well. If end. All right, doesn't need to nil, we can add it to the queue as well. All right, so the root is nil. We don't need to return anything. We set up the result list. We start off looking at the root, get the size so we can cap how big our level is. And then if this was the root, N would be. Root level would be one. We would add was it two and three to the list. Two would go first and then three. And this is just one. We would break out and then we would have one. And then next iteration, this size would be two. For two and three, This would be 2. We would add 2 to the level, we would add 4, I believe it was 4 and 5. And then we would go to 3. 3 would add to the current level and we would add five and six and then so on. So I think that makes sense. Oh, here, let me fix this. This has to be below package.
Stealthy Elephant: There you go. Okay, that makes sense. Perfect. Okay, I'm gonna provide some hover fun just to create the tree so we can start testing it. Okay, Let's just. Let me just train everything to three nodes. It. Level order, traversal. Okay. I put some skeletal function. Let's see if there's any issues. So you have some. No, we have some differences. You have your node class as left and right. Okay.
Factual Lightning: Oh, I think I did. I did lower cap.
Stealthy Elephant: Okay, let me just. I can just change that real quick. Okay. Okay.
Factual Lightning: And then.
Stealthy Elephant: Okay. And any other issues? Give me one second. See? Okay. Do you mind reviewing? Because based on the build. So I create a build tree.
Factual Lightning: Let me just fix it for you. Okay, let's think of time should be good. No, no, no. Yeah, any.
Stealthy Elephant: Let me just fix this up. Okay, perfect. Let me just change it. Okay. For a second time.
Factual Lightning: Let me just go through the studio.
Stealthy Elephant: Code so everything looks good in case. Let me see what will be the time and space complexity for the solution.
Factual Lightning: So space. I mean, we're not. I mean, we're not really holding anything extra besides using the queue. But I mean, I guess you can think of the queue. The queue will only hold the most like a amount of level. Like the nodes in the level.
Stealthy Elephant: Yeah.
Factual Lightning: I don't know what we would call that. Maybe like, I don't know if there's a formal term for that. K. I don't know. But in terms of the. The time, we're pretty much. The time complexity is just the height of the tree. Essentially perfect. We're only through. At most, we're going through. Well, we're going through like if you think of it as like an. The stairs or elevator, we're just going through the height.
Stealthy Elephant: Why would you say height of the tree for this one?
Factual Lightning: Oh, well, we're going to. We're touching every node, so I guess we can't. And we're not cutting off any time. Okay. So actually the time complexity will just be O of N because we have to touch every node, I believe. Yeah.
Stealthy Elephant: What is the space complexity?
Factual Lightning: This is where I'm a little iffy on because I'm not sure if the queue counts as extra space. I mean, technically it would because it's. I mean, it. We're creating something in memory with the queues. But the space complexity would pretty much be. The biggest number of nodes in a level, which.
Stealthy Elephant: I guess you could think.
Factual Lightning: Of that as a constant.
Stealthy Elephant: Sorry. What's your solution?
Factual Lightning: My hunch is it would be a constant space.
Stealthy Elephant: Okay, so. Right. So you say. Oh, are you saying O of 1 for this one?
Factual Lightning: That would be my hunch. Just because I could. The number of the queue will only have a level worth of nodes. I mean, that's not. It's not free. So I could see the argument where it's not o of 1. I just don't know if there's a formal term for O of the. The most nodes that the level has, you know, and you will ever have is the nodes in the level.
Stealthy Elephant: I see. Yeah. So we would say for this one, we would say all the N because when we say storage. Right. We. We want to put every node in storage.
Factual Lightning: Oh, yeah, that makes sense.
Stealthy Elephant: Yes. Okay, I know. I know what you're saying. Right. You're thinking like it will be the O of what the. The biggest level is. Correct. Like the last level, if you think that's a container, but that's not how it works in space complexity. It's more of how much space are you allocating in general. So you. You're in the right direction. It will be O of N. Okay, so I also fixed the helper function. So do you mind running the code for this one? Yes. Okay, let me see. Okay, perfect. One second. Let's see, let's see. So I had. So this example is. Okay.
Factual Lightning: Okay.
Stealthy Elephant: Yes, Perfect. Got it. Let me just make. Yes, so for this. Is this evidence. Looks good. Yeah. 392-0571. Perfect. All right, so you're able to do the solution. So we have 13 minutes left. So what I can do up to you, because I think just some small feedback, and then based on how you like the feedback, we can go off on that. Maybe you can challenge yourself a little bit more. So for the first two questions, it seems like you're in the right direction. So I think in terms of, like, staff, senior, you should be good. Just a little nitpicky things of. I saw in the very first solution how you were going in an efficient route. You caught yourself and you're, hmm, how can I make this more efficient? So that's a great catch. And just knowing how. Okay, you understood what is the lowest. How do you find the first number of the sequence? And once you were able to find that out, you definitely made a solution from O of N squared to O of N. That was great. This solution as well, you already knew off the bat, you needed to bfs. It seems like all your syntax, everything's good to go.
Factual Lightning: Right.
Stealthy Elephant: So based on this, do you want to give you. I can give you an even harder question right now, and you just give me the pseudo code of it. You can just talk to me how you would approach it and we can go from there. Would you like. Would you like that approach? Because it seems like the first two questions you understood a little bit. I think you may need a challenging, more challenging question.
Factual Lightning: Sure. Yeah.
Stealthy Elephant: Okay, perfect. So for this, for the sake of time, I'm going to copy and paste the question. And then I want you to kind of just walk it down with me. Like, just tell me what you would do, what you would code at, what type of approach you would do, and then rather even coding, I want you to write, tell me the time and space complexity. Sometimes people do ask that. Okay, okay, okay, okay, okay. Okay.
Factual Lightning: Here is Prop.
Stealthy Elephant: See? Okay. All right. So, interview prompt. So. So this is cute. On a cliff, it does not exist anywhere. I made this question myself, and usually, just for the sake of time, I put in the prompt. What I would do is I'll give you, like, a very, very vague prompt, and then what I tell the interviewee is to make the question for me, to even make it more complicated. But just for the sake of time, I provide the question. So you are a landscape designer working on a vertical cliff covered with trees. Okay. The cliff is model as a 2D grid. So let's just say there's a matrix you're given. The ones are part of the tree. Zero is like empty space, empty rock. Okay. The bottom row is solid ground. Two trees are connectable if they are adjacent. Up, down, left to right. Four directional. A tree is considered stable if it's connected to other trees. There's at least one tree in the bottom row. If a tree is not connected to any tree in the bottom row, it will fall off the cliff and disappear. You're given an M times N grid landscape of 01, a coordinate cut of RC, which is a row and a column representing the tree you cut down. Tree means the cell R comma C becomes 0 first. After that, any trees that are no longer stable and no pass through one to the bottom row will also fall and become zero. Return the resulting grid after all the unstable rows have fallen. So I'll provide you an input and I want you to kind of tell.
Factual Lightning: Me what you did. Okay.
Stealthy Elephant: So this is the example. Okay. And what I want you to do.
Factual Lightning: Is.
Stealthy Elephant: What would the output be? Okay, now this is just an example. Yes. So any questions about this question?
Factual Lightning: I think it makes sense. So I pretty much need to find the unstable trees and then flip them to zero.
Stealthy Elephant: Right? Correct. Yes.
Factual Lightning: Okay. I have a hunch on how to go about this. Okay.
Stealthy Elephant: What do you think the output would be in line 37? All right, so landscape is. So right now, landscape is this one, the cutting. The coordinate. Let me provide that cut. The cut coordinate is going to be 1, comma 3. So how would the tree look like after we cut 1, comma 3.
Factual Lightning: Oh, okay. So you cut that first and then.
Stealthy Elephant: Yes, correct. You go about the problem.
Factual Lightning: Okay. Okay. One, comma three. Let me copy this here. So this.
Stealthy Elephant: Yeah, you cut that.
Factual Lightning: Okay, so the way I would think about doing this is we know that a tree is. A tree has to start at the bottom. So what I would do is I would. I would go through the bottom and I would look for any tree at the bottom. Once I see a tree at the bottom, I would do like a DFS to find all the ones connected to it.
Stealthy Elephant: So this would be connected.
Factual Lightning: This would be connected. This would be connected. This connected. This connected. And that's it. So this would be a zero, this would be a zero, and this would. That would be a zero.
Stealthy Elephant: Perfect.
Factual Lightning: So that's.
Stealthy Elephant: Yeah, that's. Yes. One more example and we can go.
Factual Lightning: On with your pseudocode.
Stealthy Elephant: So let's just say example two.
Factual Lightning: Let's see, let's see.
Stealthy Elephant: Let's try and make this a little complicated.
Factual Lightning: Okay.
Stealthy Elephant: Okay. And let's just say the current, the cut coordinate is also. Yes. So what would be the alpha B for this one?
Factual Lightning: So cut is 1, 0, 1, 2, 3. And that comes to zero, the start. So essentially the same. So I would look through these. So this would be good. This is good.
Stealthy Elephant: This is good. This is good.
Factual Lightning: And also. That's kind of. I feel like this is all connected. I can't. Connected, connected. And then we would go here. I feel like this would be it.
Stealthy Elephant: Yeah, exactly. Yes. Okay. Do you mind providing like a pseudo code? Like he talks to me through it. I know you gave me a little bit of details. Write like a pseudocode skeleton. It doesn't have to be exact. We're not going to run it just like pseudocode golang.
Factual Lightning: Sure. So let's say we're modifying the grid in place. First off, I'm just going to assume correct input. Oh, I meant to say cut.
Stealthy Elephant: I mean it doesn't matter if it's.
Factual Lightning: A stack or so I want something to traverse the points. So we'll do that as a point.
Stealthy Elephant: And then.
Factual Lightning: And then I also want to keep track of like the length of the. Assuming the input is fine. So now from here what I could do is. Oh, no, not necessarily like this. Hold on, I need to look from the bottom. So it would be for. Let's call it J, since that's grid of. M minus one is what it would be. And then if grid of m minus one J is equal to one. Well, I guess we could. If it's not equal to one, we just continue. If it is equal to one, what would be a good thing to do? Trying to think if we would need like a. Something like a map, you know, what we've seen.
Stealthy Elephant: Yeah, that's good. Like a visited. Like a visited map. Correct.
Factual Lightning: Right. Something like that. Just so we know while we're doing this traversal whether we've seen it or not. Okay, so something like that and then I would mark it. We'll say the point is, it will be m minus one j. And then scene point equals true. And then I don't need to do this here. I could actually do this. Like this. And then it would be, oh, I could. We did P. Okay, so kind of look like that. And then essentially what. I'm trying to think, like, maybe, maybe we mark them because at the end of the whole thing I need to mark what hasn't been touched. But maybe I could just use the scene map instead of marking them as like two and then having to flip it back to a one or something. You know, I think that would be fun, actually. Okay, so something like this.
Stealthy Elephant: And then.
Factual Lightning: The points will be stack of that. And then I would get rid of it. And then the neighbors. Would be.
Stealthy Elephant: Let me.
Factual Lightning: Call this K. So I can use I instead of there. So I j p 0 p 1. So I plus 1 j I minus 1 j I j plus 1. So go through each neighbor. If. It's out of bounds, then we can. Ignore it. Or if we've seen it, we can ignore it. Or. If it's not a one, we can ignore it. Otherwise we can mark it as seen and then. Add it to the list. And then finally, like at the end.
Stealthy Elephant: Of all this.
Factual Lightning: We can go through the entire grid. If. And then say if we haven't seen this point. My thought on the.
Stealthy Elephant: Yeah.
Factual Lightning: Sometimes me writing code is easier.
Stealthy Elephant: For me to think about. Of course. Of course. Yeah. So I think. So everything's going in the right direction. Everything's pretty solid. I saw. Because I was waiting for you to make sure you check the scene, which you did at the very end. So that's very good. And what would you say is the time and space complexity for this?
Factual Lightning: So it would be if M is the number of rows and N columns, we have to go through essentially everything. So N time, M, N. And that's for both.
Stealthy Elephant: Sorry, you cut off a little bit. Sorry.
Factual Lightning: Say. Yeah, so yeah, M times N for both time and space.
Stealthy Elephant: Perfect. Okay, sounds great. Okay. Yeah, I think everything's pretty solid. So in the next five, within the next five minutes, I'll give, I'll provide some feedback. But don't worry, everything will be more in depth in the feedback I'll give you in the written. And if you can also provide some feedback at the event for me, that'll be great. So also, just to preface for that first question, I apologize for pushing that hash direction. I've just been working so much with JavaScript, Python and Java. Java. So for. For Golang. I completely forgot about that part. So I apologize on that behalf.
Factual Lightning: No worries, it's all good.
Stealthy Elephant: Okay guys, so in terms of feedback, so let me say for second question you did perfect on.
Factual Lightning: Right.
Stealthy Elephant: I guess the only issue was that space complexity, right?
Factual Lightning: Yeah.
Stealthy Elephant: So space complexity. So brush in mind that tactical actually looks fine. Everything looks good. First question. Although it was easier than the second question. I think there is a. So I know you stated that you like coding and you know, figuring out through that path, but sometimes interviewers, depending on what type of interview you had, they might not like that. They might want you to kind of verbalize what path you're going in and then start coding it up. Because sometimes they can see it in a way where, huh, I'm not sure which way I'm going to go. So I'm just going to start coding things, hoping something can stick.
Factual Lightning: Right.
Stealthy Elephant: So try to have a sense of concept before going in. Even if you're stuck in the sense of concept, ask the interviewer like, hey, like this is my logic. Do you think am I going the right direction? Is there anything that you would like I should change? Right. So it's like you kind of asking the interview, putting interview on the spot like, hey, like looks good. Confirmation. Yes. Okay, perfect. I'm gonna start coding it up. So maybe try doing that. Although I know that like try getting the habit of that. Alright, so first question and then I think you got little. This is a very small hiccup. I think I was trying to push you to understand like how do you know this is the first number of the sequence? Right. You might have gotten it maybe like a minute or two later. But I just wanted to kind of push you just to say like try to use all the data as leverage. Right. Because that was a great cache you had where you stated, huh, I can just sort it, but it'll be N log N. But I want to make it more efficient solution. Right. So you know it's not going to be sorted. We have. Whenever you think of sequences, you got to think of, okay, what's the first number of this sequence? That's a pattern that you should try to like pick up on. Okay, okay. For this question I think everything was great. You had like just for the sake of time, but you were able to understand the question very quickly. You were able to get the example 1 example 2 output even when you were doing serial code. I mean everything looks pretty solid for the most part. So yes, that is my TLDR feedback is brush in mind space complexity to try to get a solid like variable solution out and then start coding it. I think that looks more preferred. Kind of talk more about how you would approach it. Right. And just dive into the code. Okay. Yes. Do you have any small feedback for me besides I know me suggesting hash that part?
Factual Lightning: I mean, honestly, this like kind of being my first one, like, I thought it was great. I appreciated you not giving me too many hints, only like when I really needed it. That was helpful. You also weren't completely silent, which was nice.
Stealthy Elephant: But I do have to give you a heads up. There are interviewers who are just let you struggle. So I'm more of like the, like I. For me, you know, I want the best for people.
Factual Lightning: Right.
Stealthy Elephant: And you know, if you know how code, if you know how to understand the solutions on the job, you'll be just fine.
Factual Lightning: Right.
Stealthy Elephant: But I know there are interviewers out there who are just completely silent. And when you're stuck, they won't say anything. Right. So some advice as well is let's hypothetically you get an interview who's completely quiet, very silent. Okay. And you're talking out your solution. Anytime you ever get stuck or you need some type of verbal communication, tell them, hey, this is what I've done. What do you think? Right. Because I always like interviews to be a casual conversation between two engineers trying to figure out a complex problem.
Factual Lightning: Right.
Stealthy Elephant: So tell them, hey, what do you think about this? Am I going the right direction? Put them on the spot. So there's always a feedback loop. So you don't know if you're in the right direction or not. So that's the number one tip I would always provide. Okay, sounds good. And I think that is basically it. And I think other tips. So since you have you said you're going to start applying to interview, so that's good. If I can provide a little bit more advice is that since Christmas coming up, right. I think you should start applying now. Right. Maybe apply to companies that you may not be too happy about or more like for practice, start doing that now and then maybe a week later, then start applying to like the higher companies. Like you do want again to get the referrals, try filling them in. Because when Christmas comes, everything's gonna be on pause.
Factual Lightning: Right.
Stealthy Elephant: A lot of people are gonna go station. So let them let the, let the application sit. And I think by first week of January, second week of January, that's when all your interviews are gonna start piling up. Right. And hopefully like you're doing, you have Ready, like first round interviews or second round interviews by like the first, second week of companies that you're not too crazy about. And by the end of January, that's when you're like, okay, I'm very like set. I'm doing good. I'm going to do the companies that you do care about and hopefully you kind of finalize something by mid February. Like by average time mid February to end of February, you should be able to care something because based on your technical expertise, your communication, everything is looking pretty solid.
Factual Lightning: Okay, that's good to know. I had one, one question for you. I was very, I was curious about getting one of the coaching packages.
Stealthy Elephant: Okay.
Factual Lightning: For like this, for the staff level, do you find that to be worth it or. And also another question is like, if like my top company isn't necessarily a fang company, like it's Enduro, I don't know them. How do you know which one to choose? Which package?
Stealthy Elephant: Okay, sure. So the first question when you said, is a package worth it? So I started the interview in the IO. I started interviewing a few weeks ago, but I know a few people who are actual coaches for that program. Okay. And if you read briefly, I think the success rate is like 99%. Right?
Factual Lightning: Yeah.
Stealthy Elephant: And it's. There's also policy where if you're not happy with it, you can get a. Let me just double check this. Don't quote me on this, but based on what I saw last time, if you're not happy with it, you can get a refund.
Factual Lightning: Yeah, I read this.
Stealthy Elephant: Yes. Right. So I personally would say it's worth it just because based on the statistics and data and the mentor that I know, he works as a Airbnb staff engineer. He also worked as a senior engineer at Meta. So if you're interested. But he, I think he works on the Meta or Airbnb route. So if you want to get in touch with him, I can refer you to him. But TL Dr. Yes, I would say is worth it. It is a little pricey. But once again, if you're not happy with it, it's not looking so good. You can get a refund. And two, based on the data, it is a very successful rate. And then second question, you say that if you, let's just say one of the companies that you real life is not considered a faang company. You said which package should you do? Yeah, that is a good question. I will redirect that to, I think a lean learner. I think, if you don't mind me asking, which company are you trying to get into?
Factual Lightning: Yeah, their name is Enduro. They're based off of. Got it.
Stealthy Elephant: Got it. I can ask my. Ask Eline, say that, hey, is there any packages for Enduro or something similar to it? Because I know for the company specific packages, they're very, very specific.
Factual Lightning: Right.
Stealthy Elephant: So I don't want you to spend money on something that's not in the same path as Enduro. So if you know, feel comfortable. If you do want to share, contact, feel free to do so as interview. If you don't feel comfortable, I think reach out to the. I think Whoever schedules interview interviewing.IO.com or Eline Learner. I think if you just ask them questions, they will be able to answer it further. Okay, cool.
Factual Lightning: Yeah, well, I'll do that.
Stealthy Elephant: And I feel like.
Factual Lightning: I feel like I remember seeing, like you can chat with someone for like 10 minutes to discuss.
Stealthy Elephant: Yeah, a coaching session. Yes, 10, 15 minutes. You can chat with a current mentor or coach.
Factual Lightning: Okay, cool, Cool.
Stealthy Elephant: Perfect. Any other questions?
Factual Lightning: No, that's it. Thank you. I appreciate it.
Stealthy Elephant: Perfect. Thank you so much. You so much, Michael. Have a great day, man. You too.