Python Interview with a FAANG engineer.
Walls and Gates + Tennis Score Tracker
Watch someone solve the the problem: walls and gates + tennis score tracker 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.
Walls and Gates + Tennis Score Tracker: Python Interview with a FAANG Engineer - YouTube
Interview Summary
Problem type
The Problem: Walls and Gates + Tennis Score Tracker
Interview question
The first problem asks the candidate to fill a 2D matrix representing rooms, walls, and gates with the minimum distance from each empty room to its nearest gate - a classic multi-source BFS challenge.
The second problem involves designing a class to track scores for a two-player tennis-like game, including correct win detection logic, state management, and formatted score output, testing both object-oriented design and careful reading of game rules.
Interview Feedback
Feedback about Nimble Torch (the interviewee)
Advance this person to the next round?
Yes
How were their technical skills?
3/4
How was their problem solving ability?
2/4
What about their communication ability?
3/4
Strengths & what went well
You solved both problems during the interview. Your short comments while coding were helpful and made the structure of your approach easier to follow. Your complexity analysis was good, and you were able to keep making progress through debugging.
Areas for improvement
For the BFS problem, the overall approach was correct: starting from all gates and using BFS is the right direction. The main improvement is to make the expansion logic simpler. The solution had duplicated neighbor loops and extra distance-calculation logic, which made it harder to follow. In BFS with equal-cost moves, the first time you reach a cell is already the shortest distance, so you can update it immediately from the current cell. For the scorekeeper problem, clarify the required behavior before coding, especially what state needs to be tracked and what each method should return. This would help avoid changing the state model midway and make the implementation more direct. Debugging was slower at the beginning, and edge cases were not identified early. A useful habit is to test with one small normal case and one edge case before doing deeper debugging. Advice for future interviews
Do not spend too much time on Python type annotations if they slow you down. Use that time for clarification, simpler implementation, and testing. Continue practicing Python basics so the implementation details feel more natural.
Feedback about Metal Turtle (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?
3/4
How helpful was your interviewer in guiding you to the solution(s)?
4/4
that was a fun warm up interview!
I agree with interviewer's feedback.
Interview Transcript
Metal Turtle: Hello?
Nimble Torch: Hello!
Metal Turtle: Hi, can you hear me?
Nimble Torch: Yes.
Metal Turtle: Do you hear me? Yes, I can hear you. Um, yeah, so let me give you a breakdown of how, um, we're gonna spend the time. Uh, first we can do a really quick, uh, intros. Then we're going to spend most of the portion in an actual, um, doing the actual mock interview. I've prepared a couple of questions, um, and then at the end, 10 minutes, um, for me to provide feedback. I'll try to, yeah, like, uh, highlight or point, um, any thing that I think will help improve or improve the interview performance. So first, I can start. I've been a software engineer for 8 years, been in mostly mid to big, mid-sized to big tech companies. Working on the backend, so backend and platform engineer.
Nimble Torch: Yeah, sure. Yeah. So yeah, nice to meet you. My name today is, what is it called, Nimble Torch. Yeah, I've been in tech for Yeah, more than 10 years by now. I actually stopped counting. And yeah, I work in a fairly big company as a backend engineer, but I switched teams multiple times. So kind of been here and there. Yeah, willing to switch, actually. I'm targeting [REDACTED] right now because they scheduled the interview out of nowhere, to be honest, because yeah, it's just like that. So I'm not sure whether I prepared or not, but I'm willing to give it a shot. Yeah, so if you have some problems kind of that's related to [REDACTED], that would be great. But as far as I know, they will give me 2 problems at once. I mean, like one after the other. Yeah, so let's see what happens.
Metal Turtle: Yeah, we can try to target solving 2 problems in this interview. Yeah, I know [REDACTED], like, they— most companies usually have like one large problem and they will ask you follow-ups. But [REDACTED] is more— I think they care a bit more about the speed and they will ask you like 2 problems and also complexity as well, like time complexity or space complexity.
Nimble Torch: Yeah.
Metal Turtle: But yeah, like I think the interviewer sometimes like asks you different types of concepts like graphs and trees or recursion and sorting. So yeah, okay. So in this, so let me paste this problem and feel free to choose any language that you feel comfortable with.
Nimble Torch: I will choose Python.
Metal Turtle: Okay.
Nimble Torch: Let's see.
Metal Turtle: Yep, it's like this.
Nimble Torch: So, paste it. Multi-source BFS walls and gates given 2D matrix of Rooms in building. Update metrics of every room contains distance to its nearest gate. If empty room cannot reach any gate, leave it as -2.
Metal Turtle: Okay, -1.
Nimble Torch: Can, um, so I'm getting, uh, a 2D, uh, array, I'm assuming, right? Uh, 2D list, list of lists. Uh, -1 is a wall, 0 is a gate, and -2 is an empty room. From a room, you may move up, blah blah blah, down, left, or right. Update matrix. So every room contains distance to its nearest gate. If empty room cannot reach any gate, leave it as -2.
Metal Turtle: Let me paste to the top.
Nimble Torch: Yeah, cool, that is very helpful. 0 is a gate and -2 is a theorem. Nice. Okay, I think in that way, I think the trick for this problem is to actually start from the gates. So it's going to be a BFS and we start from every gate and in each round of DFS we will be trying to reach from our current set of cells in the BFS to the neighboring cells that we haven't visited. And once we reach the empty room, we will update it with the distance from the closest, from the closest neighbor. I think that is the gist of it. So we will have to keep track of the visited cells and we need to also keep track of the distance from each of the Yeah, the distance to the closest gate. Yeah, that's the idea.
Metal Turtle: Just one clarification, or one thing to keep in mind, is that you, in this problem, you can modify the matrix in place.
Nimble Torch: I can or I cannot?
Metal Turtle: You can, yeah, you can.
Nimble Torch: I can, okay. That kind of simplifies it, I guess, simplifies this, I guess, because distance will be always positive, will be growing positive, and wait, but then If we are only changing empty rooms, right? Uh, minus 1. And we are only going through the gate, right? Uh, minus 2 empty room, minus 2 empty room.
Metal Turtle: Uh-huh.
Nimble Torch: Uh, I see. Well, in that case, we just traverse the matrix from the zeros, and whenever we see -2, we get— well, yeah, we update the distance to it, and yeah, we kind of keep going. We are adding -2s to our list that we're going to iterate in the next cycle and we keep going till we are finished. That's kind of it.
Metal Turtle: Yeah, that sounds reasonable to me. Feels safe to implement.
Nimble Torch: Okay. And, uh, kind of like that. All right, yeah, if I understand correctly, we don't care too much about the size because we will have to traverse the matrix once anyway. So yeah, we don't need any memory and anything. Apart from our data structure for BFS. So let's call it layer. Okay. I'll just keep track of the size. Item list equals to tricks and tricks 0. Yep. Then we traverse the matrix. And we're accumulating gates. And you know, I'm thinking, uh, so instead of using a list, I want to use I want to use— oh, probably it's fine. Probably it is fine. Okay, so we are appending i and j, right, in the form of a tuple. Okay, that's, that's probably gonna be the first part. Number 2, calculate distances. Yep.
While we have something in our layer, say What is your language of choice, by the way?
Metal Turtle: Uh, for interviews it's also Python.
Nimble Torch: But in general?
Metal Turtle: Um, Python as well.
Nimble Torch: Nice, good.
Metal Turtle: Good choice.
Nimble Torch: Okay, so that and blah blah blah. So here we are starting with the gates. We don't need to update gates yet. So if matrix at, actually, CIN, CJ, we will unpack it right away. If it is a gate, then for i J, N. So up, down, left, and right. Okay. I— if this matrix, if the cell equals to -2, means it's not updated. Then we say append i and j. Okay, and we continue. If not, means it's currently a room. In this case, we first need to update its cost, kind of like that.
Metal Turtle: Uh, if I hit—
Nimble Torch: this is the bug. C i plus, this is C j plus. Okay, um, so it either can be 0 Or more, and minus one is what? Minus one is a wall, right? Zero or more. Yep. Greater or equals to zero. Then minimum neighbor equals to min between minimum neighbor and that. Ah, I think here's the bug as well. So I need to check for Boundaries, right? And here as well. So we have minimum neighbor, and then we say matrix at ci and cj equals to min_neighbors plus 1. Okay, we have updated the cost. And then we can kind of do the same thing over here. Right, I think we need to flip logic here. So here we do If matrix equals to -1, then we are updating the cost. Otherwise, we only do this part. And I think that that will give us what we want for— what do you think? Any thoughts?
Metal Turtle: Yeah, I'm wondering The way that you're handling like the empty cells is like you have this first condition here and then this, and then you always check in the 4 directions.
Nimble Torch: Yep.
Metal Turtle: Uh, got it.
Nimble Torch: Yeah, because we are starting from the gates, right? And, uh, we are only, uh, adding empty rooms from there. Uh, that's the idea. And, uh, here I check if this is the empty room, then we are updating it. And if, if it's not Then we adding them to the layer. I think this is— what is it? Is this a mistake? -2. So -2 is what? -2 is empty room.
Metal Turtle: That's correct. Yes, -2 is empty room.
Nimble Torch: Right. And here, I think this is the bug, right? This is -2 as well because we are only updating it in case of the room.
Metal Turtle: Yeah, this is okay. This, I think it makes sense. Uh, so because you're checking by the -2, like only the empty cells, then that way you don't worry about— you don't, you don't have to worry about the, the walls. So that makes sense. Um, yeah, uh, yeah, I, I can follow the logic. Um, feel free to complete the, the boundaries check and we can test it.
Nimble Torch: Sounds good. Um, I kind of like it, uh, so that's If i— ci plus i is greater or equal to 0, and ci plus i is less than height and cj plus j is greater than or equal to 0 and cj plus j is greater than w and that. So that's a little mouthful. I usually do it the other way around, but in this case Yeah, I think it's probably okay to keep it that way. A little messy, probably I'll need to do some refactoring. So ideally this should go in a sub-function or we need to do some like other refactoring. That's what I think.
Metal Turtle: Yeah, that's fine. Feel free to— I mean, since we only have a function, I recommend you for testing we can just have a function without the class that will facilitate testing a bit. And then the 2 test cases, feel free to use— I have, okay, I have a couple more.
Nimble Torch: Let me— You want me to test it or you want to work?
Metal Turtle: Yeah, I have more test cases, but Feel free to use the ones that you have there to test.
Nimble Torch: Sure. Okay, let's, let's try doing that. Uh, all right, so, uh, height in this case will be 2, uh, and width will be 2 as well. So i for the range From 0 to 2, j is 0 to 2. If matrix is, uh, 0, then—
Metal Turtle: Oh, you, you don't need to test it manually, test by step by step. You feel free to run it, like to run the code using the samples.
Nimble Torch: Um, I'm not sure that is— how, how do you run it? Do I just run it?
Metal Turtle: Yeah, actually. Okay, let me— I generated this. to help you. And this, so for example, you can do something like this. Um, you can just do something like—
Nimble Torch: Oh, I'm, uh, yeah, I don't, I actually don't know how to write unit tests in Python. Sorry about that.
Metal Turtle: Okay, so you can use assert and this will like, if it fails, but you can just simply Uh, also, if you just, uh, want to print, uh, you could just do something like, um, you can print it in the, in the function or here in the results. Either way is fine. But yeah, like, um, yeah, you don't need to use assert or be knowledgeable if you want to. Okay, okay, I got it.
Nimble Torch: I just need to compare the result. Okay, let's see. Uh, does it do anything?
Metal Turtle: Uh, I think it is running. It's still running, so it's getting stuck in some kind of loop.
Nimble Torch: Really? While I'm supposed to pop e, how about print ci call cj, and we'll see what happens. Python.
Metal Turtle: Okay, it finished. It finished. Okay, I think let's comment this because I— and see if it runs.
Nimble Torch: Um, let's see.
Metal Turtle: But it does take a while. That's interesting. I'm looking at the Uh, oh, because if you look at the— it seems to be processing the same directions all over again. Did you look at the print that you just printed?
Nimble Torch: Oh yeah, interesting. Uh, ah, I see. Wait, ah, because we, we are— I see, I see, because we are We are— what's going on? So we added— we added— wait. So I see J, neighbor, blah, blah, blah.
Metal Turtle: Ah, okay.
Nimble Torch: Wait, this is the bug. This is debug plus i and this is plus j. Okay, and here it's also ci plus i and cj plus j. But wait, uh, why this is highlighted? Possibly unbound.
Metal Turtle: Ah, for Because i and j, yeah, you can access those there.
Nimble Torch: I see. I think this is, this is correct. This is that neighbor. What about this one? Yeah, this one, this one is legit. This should be that way.
Metal Turtle: Run it. I'm pressing run, but it's not running. Like, I'm not sure why. I'm pressing the run button, but it's not running it. Can you try running it?
Nimble Torch: Just wanted to make sure. After run. Let's see.
Metal Turtle: Um, yeah, uh, it is interesting, but this, uh, what is that?
Nimble Torch: Before run, is that—
Metal Turtle: I don't, I don't think it's— now it's not even running. Can you, can you try to run it? Can you try to press in the run button? I don't think it's working for me.
Nimble Torch: Yeah, you see before run, after run?
Metal Turtle: I don't see. Well, I—
Nimble Torch: So I see this result. Oh shit, why it's not copied?
Metal Turtle: Can I copy it?
Nimble Torch: Copy. I cannot copy.
Metal Turtle: Why I cannot copy?
Nimble Torch: Let me—
Metal Turtle: I'm gonna refresh my page. That's so weird. Okay, can you hear me?
Nimble Torch: Yes, I think it produced results.
Metal Turtle: Okay, I see it now. Yeah, I think something was happening with my browser. I see the result, but that's kind of It doesn't seem, it doesn't seem like the— oh wait, is it the right output? 3, wait, let me—
Nimble Torch: Probably not, there's some— something should be off.
Metal Turtle: Yeah, let me, I'm gonna paste this. This is just like uses the SR but you don't You don't have to worry about that, but yeah, if it— oh wait, did you run it? Okay. It actually—
Nimble Torch: Ah, I see, I see, because I initialize it with— shoot, with 0. I should have started with something, I don't know, maybe like this. That should do it for sure. Oh shoot, what the hell is this? Well, I'm not sure how to interpret it.
Metal Turtle: It shouldn't even like print Okay, shoot.
Nimble Torch: Oh, why so many? Ah, this is test BFS.
Metal Turtle: Yeah, but I— okay, hey, I just want to make sure that this is actually entering. Is it showing entering for you?
Nimble Torch: Um, I see the greater— 3 greater signs. Uh, right, the Python, uh, prompt.
Metal Turtle: And, uh, oh, I'm sorry, I know why. Like, we are not calling the test, so nothing was running.
Nimble Torch: Entering.
Metal Turtle: Okay, entering. So it's actually happening, the test is passing the test cases. Yeah, nice. Yeah, yeah, because if, for example, let's say I'm going to modify this to an invalid case, and so it will complain. Ah, see?
Nimble Torch: Oh, nice.
Metal Turtle: Okay, yeah, so the solution is working. We can— let's go to the second problem, and then I can give you feedback for this first problem at the end. But yeah, you were able to solve it.
Nimble Torch: One sec, one One sec, I think something's wrong with my device. Okay, go ahead please.
Metal Turtle: Okay, let me, I'm gonna paste it here. This problem is more about kind of data modeling. So not sure how familiar you are with tennis. But let me— okay, so paste this and then the rules.
Nimble Torch: Track score for 2-player tennis-like game.
Metal Turtle: Yeah, I'm gonna paste, I'm gonna paste the rules in a moment. Okay, here, the rules. And then you can, yeah, feel free to start with, uh, let me give you a starter, um, definition, class definition.
Nimble Torch: Yeah, yeah. So getScore returns the difference? Or why there's a minus between points?
Metal Turtle: Oh, this is kind of more like a— it's a string. So it's like the point dash. Oh, I see.
Nimble Torch: It's a dash.
Metal Turtle: Exactly.
Nimble Torch: Yeah, understood. So only 2 players, right?
Metal Turtle: Only 2 players, yeah. tennis, I mean, there is 4 players, but for now, let's, let's, let's, uh, we're only going to worry about 2 players.
Nimble Torch: Gotcha, gotcha. Um, uh, in that case, uh, probably we can do this, right? So I'm thinking to keep a score in the, uh, in the dictionary. And, um, right, uh, just 2 players, right?
Metal Turtle: Just, just one reminder about Python, if you're gonna use the init, uh, oh yeah, and then you need to put the self. Uh, like if you want to define class variables, you need to put self here and then— yeah, so that's how you define the variables in Python.
Nimble Torch: Yeah, yes, thank you. Uh, this, uh, default dict not defined. Oh, I'm supposed to import it. I don't really want to. Can I leave it like that?
Metal Turtle: You can use it. If you don't remember, sometimes in the interface they let you search on Google, but I think for default deck, I think it's from collections, import. Yeah, just like that.
Nimble Torch: Oh, awesome, thank you. So that, um, and, uh, this will mean self.default dict at player Both players start with 0, plus equal to 1, and that should do it. Do we care if like there's another player hits it or do we need to care about it?
Metal Turtle: What did you— what do you mean if there is another player? Oh, you mean in the addScore?
Nimble Torch: Yeah, if somebody calls addScore with player 2. Player 3, for example, something like that. Do we care? What do we need to validate the data?
Metal Turtle: Yeah, uh, don't— you don't need to write the code, but what, what could you do if— what do you think we could do if, if we receive a player that is not player 1 or player 2?
Nimble Torch: Yeah, yeah, yeah. Do, do we care about it?
Metal Turtle: We don't. And I'm just— for this problem, we can assume that the player is valid, but what I'm asking, what do you think we should do, or how could we handle invalid— an invalid player?
Nimble Torch: How could we? In the init function, we can Add, probably instead of using default dict, in that case we will have an ordinary dict with the keys player 1 and player 2, and we'll initialize them both with zeros. That should do it. And in add score, we'll check whether this key exists in the score dict— I mean, this player— and if it's not, then we return immediately. throw an exception or something.
Metal Turtle: Okay, uh, yeah, that sounds reasonable to me. Um, yeah, don't need to implement it. Uh, feel free to assume that player is valid. Gotcha, gotcha.
Nimble Torch: Okay, um, all right, uh, player wins. Player wins when we do addScore, correct?
Metal Turtle: Player wins. So the player wins depending on the conditions. And the idea is that once the player has won, like, you shouldn't keep incrementing the score.
Nimble Torch: Okay.
Metal Turtle: Underscore.
Nimble Torch: Predict at k. So that adds 1. Ah, I think let's do it that way. Yep, and at the end of the day, we say Like this, right? So we basically concatenate it, uh, with the dash in the middle. Uh, if player 1 returned, player 1 wins, or player 2 wins. Let's score. Um, uh, Okay. So we need to find the score of the other player. Um, at least 4 points and lead—
Metal Turtle: what?
Nimble Torch: Player wins when they have at least 4 points. Greater than 4, greater than or equal to 4, and this, uh, minus k at least 2 is greater or equal to 2, return player plus space wins. Shouldn't change the score. Why? What is that? Not accessible to return type None. Wait, in return we should print it, right? I'm assuming.
Metal Turtle: Correct? Correct.
Nimble Torch: That should do it, right? Uh, finished equals to false, and, uh, self.finished return, and self.finished equals to True.
Metal Turtle: Oh, the player wins should be printed in the getScore, not in the addScore. This line, that should happen in the getScore, not addScore.
Nimble Torch: Ah, I see. Then let's see, winner has to give winner Okay, and winner will be player, and here we say Length of the winner is greater than 0, then print shoot. Winner plus who wins is correct. Player 1, return. This is a little bit, uh, I don't like it. If player 1— oh, here I just return, right?
Metal Turtle: So if someone has won, you printing is fine, but if someone has won, we don't care about the score. We don't— we just care that they, they won. And then, then you, you don't need to, to um, to show the score.
Nimble Torch: To, to do anything. Okay, okay, I think that that should do it then.
Metal Turtle: Yeah, let me paste some test cases. Let me find them. These are some— then we can comment the test BFS. Could add score and then the get score.
Nimble Torch: I don't see anything.
Metal Turtle: Yeah, because we are not printing anything. Uh, I'm just gonna, um, print.
Nimble Torch: Okay.
Metal Turtle: Yeah, I'm just gonna print and then return instead. And then, um, none. It's gonna make this none and we can just print. Yeah, it's— oh, I mean, learning is the last statement, so okay, player 1. Oh, one, I guess, one clarification about the player 1 points. So I think we don't need this, the kind of the player name in the score. Yeah, this is— yeah, yeah. So 3-3, 4-3, and then player 1 wins. Yeah. And the— yeah, and so I'm gonna— I think part of the core of this function— Okay, we have— let me just check one more thing. I'm just gonna comment the return here when someone wins and then fight3. Then I'm gonna keep adding here. Yeah, so yeah, like the idea with addScore is that when a player has won, you shouldn't increase the score after someone has won. So that looks, yeah, that looks correct to me. Okay, so yeah, well done. So let me— I took some notes. I guess, yeah, we can discuss about the interview and feedback. So yeah, I'm gonna first kind of overall feedback and then focus on each problem. So yeah, for interviews, like especially for Python, I think one of the nicest things is that You can do like, you can write short code to do something that other languages will take more, more, more, more code. But I saw you just spending some time like adding the types. And depending on the interview problem, sometimes you have like multiple functions or multiple parameters, you can, once you agree with your interviewer in the solution, in the strategy, usually I found that it's okay. Like you don't need to worry about declaring the type because that might slow you down.
Nimble Torch: Yeah.
Metal Turtle: I mean, in the first flooring, it was only one argument, so it wasn't a big thing, a big deal. Yeah, you were writing like multiple methods and then like, I don't know, 3 parameters, 4 parameters. Instead of writing the type, you could spend writing the solutions. And that's one thing. The comments on the first problem were nice. Yeah, like were short and explained like the different parts of the approach. And the other thing, I think the time distribution was, was good. I mean, for 1 hour, you spend like half and half between the 2 problems. I'm not sure if [REDACTED] interviews are 45 minutes or 60 minutes, but keep that in mind. Because you, you might want to time yourselves. Like, I mean, once you confirm with the interviewer and they send you the invite, uh, um, like usually the interview will be intros first, like less than 5 minutes, and then at the end, 10 minutes for questions. So usually remove like 5, like 10 minutes from the total time, from the duration of the interview, and then that's to— that's the total time you have for problems. So you can use that to keep that in mind. And I mean, obviously resolving the problem is stressful, but kind of keep track of how much time you're spending, how much time is left. Because for [REDACTED], I think they do care a lot about solving both problems, or if not, one problem and getting close to solving the second one.
Nimble Torch: Yeah. Yeah.
Metal Turtle: So that's another thing. And I guess now about the, the, yeah, about the problem. So something that I noticed in common is that there were some clarifications or details about the problems that they were in the problem statement, but you kind of— they weren't that much— they weren't clear, or you kind of skipped over. So for example, in the first problem, you can change the matrix in place, and that makes the solution simpler.
Nimble Torch: Mm-hmm.
Metal Turtle: So yeah, like, and then the second problem, I think because the second problem had a lot of rules, It was kind of like something that you could do for the second problem is that you can try to just like simulate a game, like just write like something simple like 1, 1, 1, 2, and then kind of, and then confirm with the interviewer, oh, this is how the game looks like. This is how the— This is how I'm supposed to calculate the score to make sure that you understand the problem. Because yeah, I think in the second problem, I noticed that you were checking the rules in the middle of solving. So that, that, that slows you down. And about the solutions, so about the strategies. The first problem, so the solution was kind of initially a bit hard to follow just because of the way that you do the logic. So the logic works and it solves the problem, but for this problem, there is like, If you— so you're using BFS, and so you know that every time you keep expanding the, the positions, like the, the, the way that the queue works is that you pop the first element in the queue. And so the first time you you assign a distance to a cell, it's going to be the mean distance. Like, you don't need to check for mean distance because you are, you are starting from this, from the, from the, the cells with no distance, and then you're just increasing one by one by one. And because of DFS, you're increasing layer by layer. If you were doing something like DFS where, or I mean, not necessarily DFS, but like something when, when you know that the increment or like is more variable or you can assign a smaller number later, then in that case you might need to worry about min. So yeah, I think the first problem, the solution, you can simplify it a bit just by like knowing how like the how BFS works and you could simplify these 2 loops into, into a single one and that, that will make the solution like easier to follow. The other thing, this is a small detail but some interviewers care about it. So you use the list for the layer but this layer is supposed to be a queue, right?
Nimble Torch: Yeah, yeah.
Metal Turtle: Yeah, so if, if I were to ask, um, I guess, yeah, I didn't ask you, like, what do you think is the time complexity for, uh, for this problem, for the, for the solution, the time complexity?
Nimble Torch: Um, it's gonna be linear because every cell is being added to to the cell, to the layer once. But yeah, you're right, because we are using the list, might be kind of on the slower part.
Metal Turtle: Yeah, so this solution, if you use a queue, I think this is going to be the number of rows multiplied by the number of columns because you process all the cells in the worst case. And yeah, like this operation is linear, like the popping of a list of the first element is linear because you are shifting all the elements. So—
Nimble Torch: Right, right.
Metal Turtle: I think depending on interviewer, you can just take the interviewer, oh, I'm gonna use a list as a queue, but I know that, like, and if they ask you about complexity, or assuming that this is a queue, then the pop is constant. But otherwise, if you want to use like an interview queue in Python, you will do something like deque?
Nimble Torch: Yeah.
Metal Turtle: And then, yeah, you will just use deque and then poplet. Yeah, yeah. So keep that in mind because, I mean, I've seen people using lists as a queue and no problem, but if they argue about complexity, either you don't need to change it, Just make sure that you're clear, like, oh, this, I'm assuming that this behaves as a queue. So this, like the complexity of this operation is constant because it's a queue. But yeah, I'm not using the library, I forgot, that's fine. Let me see what else. Yeah, so I think related to that, um, for the— in the second problem, I also like when you were doing the initialization and like the cells and the, the class attributes, um, uh, I just struggled a bit. So I think it's good if you spend some time like looking at Python basics, uh, or like, uh, like studying over Python basics because simple things, simple operations, like in an interview, like they might ask you, oh, you need to design like a new data structure, you need to do this algorithm, and you need to know like how to use like, oh, how do I create a tree? How do I create a graph? Like being able to do that, like the faster you can do that, the more time you're gonna have to solve the problem. So yeah, let's use Python basics. And the second problem, the last— yeah, this is the last comment. You realize that at some point that you need to add the— initially you added the finish and then you added winner. I think you realize that winner gives you the same as finish but more information because finish is just a Boolean but winner gives you the name of the winner. So yeah, like, I think this problem is more about like the beginning, yeah, like defining the right state, like what is the state that you care about. So in this case, I think these 2 is the most that we care about. And yeah, like if you don't have a way to track winner or winning, then you would be kind of gonna be hard to solve this problem. But yeah, so like for problems like this, thinking about like what's the right state, and that's kind of related to reading the problem, clarifying with the interviewer what they expect, what they want, because sometimes even the same problem might be different based on what the interviewer expects. Some problems might be super vague, and so if you ask the interviewer, oh, can I assume that this is— can I assume that the input is well-formed? Can I assume that the that the digits or that the input is only positive numbers. Like, think questions like that or assumptions like that are going to make your life easier and simpler to solve the problem. Yeah, I think that's all the feedback I have. I'll make sure to write like a more detailed version of what I told you on the feedback, but Yeah, I think overall you were able to solve the problems. I think like my one of the— if I had to pick one advice or feedback is the like timing yourself and practicing like especially for [REDACTED] like that you're solving 2 problems within— I mean, if the interview is 45 minutes, so like 35 minutes, like 35 minutes. 45-minute stops. If the interview is 1 hour, then 50 minutes. But yeah, like making sure that you're kind of getting to that pace. Because if you spend like 30 minutes in one problem and then, and then the second problem is hard to follow, hard to understand, it's gonna be hard to complete both problems. So yeah, that would be kind of my top recommendation.
Nimble Torch: Mm-hmm. Got it. Okay, thank you so much.
Metal Turtle: Yeah, hope the interview prep goes well. I know that it's stressful and or can be kind of, I don't know, like interviewing is not fun. Most of the time. Yeah, but yeah, I hope you have good luck on the interview and yeah, have a— like, not sure where, what time zone are you guys, but yeah, have a nice rest of the day.
Nimble Torch: Yes, thank you, thank you.
Metal Turtle: Likewise.
Nimble Torch: Yeah, it's 9 PM on my side.
Metal Turtle: 9 PM? Oh, same, also 9 PM.
Nimble Torch: Yeah, PST time.
Metal Turtle: Oh, okay. Yeah, West Coast, same. Okay.
Nimble Torch: Okay, bye-bye.
Metal Turtle: Bye.