We helped write the sequel to "Cracking the Coding Interview". Read 9 chapters for free

Java Interview with a FAANG engineer

Watch someone solve the number of unique islands 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

Number of Unique Islands

Interview question

Given: A 2D array of integers representing land and water. Values of 0 represent water. Values of 1 are land. An "island" is a set of adjacent (N, S, E, or W) values = 1. Your task: count the number of unique island shapes. For example: [[1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 1, 1, 0], [1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 0, 1, 0]] There are four islands. The islands in the top left, and bottom 3rd column are the same shape.

Read more about the questions

Interview Feedback

Feedback about Hyper Bandit (the interviewee)

Advance this person to the next round?
Thumbs upYes
How were their technical skills?
3/4
How was their problem solving ability?
3/4
What about their communication ability?
2/4
Great interview. Good intuition and approach. Some prompting required to head in the right direction. What went well: - good questions to scope the question (minimum size, rows the same width) for your solution - great initial approach for the easier part of the question - good intuition for solving the second part of the question and good initial solution with a little prompting - good problem-solving when confronted with edge case scenario and "don't quit until you find out why" approach to resolving it - good reaction to hints/corrections Room for improvement: - variable and method naming. SIngle-letter variable names should be reserved for simple loops where you don't need the value out of that context, or for meanings that are obvious (l = length, w=width was fine, r for row and c for column would have been better than i, j) and "helper" methods should say what they are doing (for example dfs().). THe more clear you write your code the easier it is for the interviewer (or in production code, future-you or your teammates) to understand what's going on with the code. - some moments of silence as you thought, hard for me to know what you were thinking or offer prompts - parameter mutability. At one point you tried to pass an int (you changed it yourself but maybe for a different reason), and later a String as a method parameter, thinking perhaps you could modify it in the method. Understand when you can / can't do that. (Really good recovery when prompted to use a StringBuilder instead.)

Feedback about Metal Taco (the interviewer)

Would you want to work with this person?
Thumbs upYes
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

Metal Taco: Hello. How are you doing?
Hyper Bandit: Good, how are you doing?
Metal Taco: Fantastic, thank you. A pleasure to virtually meet you. Looks like we have a standard algorithmic interview for today to help me target the interview appropriately for you. It would be helpful as much as you're willing to give me the information to know kind of what your experience level is right now, what I have anonymously, it just tells me you have, like, zero years of experience. You're a college student level, which is fine. If you got any more insight to that or experience that you want to reveal, that's great. And then if you could, any general companies or levels you're targeting there, it would be great.
Hyper Bandit: Okay. So you can call me Jason. I'm now a new graduate student, and I have no work experience before, and I'm going to have an interview for TikTok next week, so I'm prepared for it.
Metal Taco: Okay, great. Not so sure about TikTok because I haven't been there, but did you say you have no experience? So this is kind of your entry level position?
Hyper Bandit: Yeah.
Metal Taco: Okay, wonderful. I can definitely try and help you out there. Appreciate you sharing that bit of insight. And let me go ahead and share just a little bit of standard guidance that I give to everybody that I give interviews. And I actually give this in real life interviews as well, just so people know what to expect. There's a couple of goals for this interview process. A lot of times you're like, hey, I'm never going to use this algorithm, actually in the real world. And that's probably true in most cases, but there's a couple of goals for the questions that we ask. And when I say we, this is me in this practice interview. And when you get your actual interview, you'll get some other random theoretical thing that you'll never actually use in real life. But there's two goals for that. One is just to show that you can write code. You'd be surprised how many people get to a coding interview and don't actually know how to write basic code. So demonstrating a little bit of proficiency in the language that you claim to have proficiency in is always great. And then a second goal is to learn how you think and how you solve problems. So typically the questions you get are kind of going to have kind of an easy half of them where you write the basic part, or it's not even efficient code. But then you need to start thinking creatively and using your knowledge of the language and certain constructs to do other ways to solve the problem than maybe the one you solved the first time. So those are kind of the two main goals. Don't worry too much, especially in this practice interview. Don't worry about typos or style indentation, all that kind of stuff. It's the algorithm or how you think that's the main focus of this interview. Do please think aloud. The worst thing you can do is just type and struggle and not say anything. And I can only watch and see what you do without actually learning how you're thinking. Or maybe you had an idea and you rejected it. That's actually good information for an interviewer to know, is if you think that something's a bad idea, just go ahead and say that. And that communicates to them that, you know, this is an inefficient approach or this doesn't work because whatever. So anything you can communicate as you think through it is helpful to your process. Don't worry about mistakes. 90% of the time in these interviews, people make mistakes. It's usually fine. Sometimes they find it themselves later. Sometimes I point it out. As long as you quickly say, oh, yeah, that was stupid. I mean this, it's totally fine. So, sound good? Ready to go?
Hyper Bandit: Yeah, that's good.
Metal Taco: All right, fantastic. In the upper right corner of your screen, you see something that says plain text as a drop down. If you click, you can language of your choice, which you just did, which appears to be Java. So that's great. And then the previous comments are here at the bottom. And I will be posting, actually, I'll go ahead and post it up at the top of this class here so that you'll have a place to refer to it. Okay, so your lucky question today's. SoRry, I'm copying and pasting something here. All right, so I am giving you a two dimensional array, and you can see the example there starting on line nine. And it is an array of integers, ones and zeros, representing land and water. If you see a value of zero, it's water. If you see a value of one, it is land. With me so far, okay. An island is connections of contiguous ones that just form a group of land. So you can see, for example, on the top row, starting in the upper right corner, there's a one to the right and then two ones below it. And I've actually put some examples down there on line 21, you can kind of see that represented as the first island.
Hyper Bandit: Cool.
Metal Taco: See, in the lower right hand corner, there's a second island. It's got a one in the top right, and it goes to the right one and then down one. So that's the middle column there, starting on line 21. You can see that as an example. And then finally there are two islands. Sorry, there's a third island. It's on row ten, the Fifth column over. You've got a one. You go right by one and then down by one. So that's the third column shown on line 21 as a third shape. There is a fourth island on line twelve of the code. Third column over. And you can see it looks the same as the one in the top left corner. You start, you go to the right one and you go down two ones. So it's the same shape of island. So there's four total islands, but there's only three uniquely shaped islands. So your goal is to write an algorithm that will tell me that there are three island shapes in that nature.
Hyper Bandit: Okay, yeah, I think I understand the question. So I'm thinking of doing it by this week. And I want to look from the top left to go through the whole 2D array. And once I meet one space filled with one, I will use a helper function and to go through all the adjacent space. And if they are also one, I will redo this work. And once I done with one, I will modify it to zero and keep tracking all the adjacent one and keep doing it until I cannot find one of all the adjacent all. I touch the boundary.
Metal Taco: Okay.
Hyper Bandit: I will look like using this method to loop this whole map and count the number of Allen. Good.
Metal Taco: Okay, that sounds like a good approach to start with. Obviously you'll hit some more details when you get implementing it, but go ahead and get started and see where you get.
Hyper Bandit: Okay, cool. So can I assume that I will get the input as this one to the array?
Metal Taco: Yes, you can assume I'm giving you that array's input. You can probably even copy and paste it into your code if you wanted to actually run it.
Hyper Bandit: Okay. In server called Kong to store the number of items. And I will like, first I'll get the learn some waste of the map it. So do we know like the lower boundary of the lens and width? Can they be zero or something?
Metal Taco: Good question. Let's assume that it's always going to be non zero. And then since you sort of assumed it, I'll just tell you, you can assume that it's going to be rectangular, that all of the rows are going to be the same.
Hyper Bandit: Okay.
Metal Taco: The length of the first one will work for all of them. That's fine. That's a reasonable assumption.
Hyper Bandit: Okay. They are at the same length. Good. So just like use Y integral to edit and I will do the loop it. And if we have island in this space, it will be equals to one. So here I will like enter helper function and I will input the map. Also input our count to it.
Metal Taco: All right.
Hyper Bandit: And then at last for this function, we'll just return the count and then we will have to write our helper function. One is our map and no, we don't need to input the comp. I think we only to here once we have a one.
Metal Taco: Okay.
Hyper Bandit: Yeah. And I will likely look for the boundaries we will like first. Before we enter our helper function, we need to modify this phase to zero and we then go through the, actually we can do this in the Helper function, delete this count, do this in the Helper function. And then we go through the first check if we meet the boundaries since this will be the above above our current cell it. Wait a second. Yeah, we need to input our coordinate. I didn't know this before. So we will have I and J two for the rows and columns and J we'll do the similar for other three adjacent sales. I think just like copy paste this one. Just like not elegant. It it. J minus one. J plus one. It. This way. I think we will get the result and we can have few test cases to try. If it is good, you it T 2D map right here and we just use the example case.
Metal Taco: Okay.
Hyper Bandit: Can I initially like this? I think I can do this. Can't output the result. I will try to write to see if there is some bugs here. You think it's good? Maybe I can't initial practice because.
Metal Taco: I think with Java you may need to use a different syntax for that array.
Hyper Bandit: Yeah. Maybe an it it.
Metal Taco: Try it with curly braces. I think.
Hyper Bandit: That I need to use a different. Use it.
Metal Taco: There you go. We nice if all the different languages use the same syntax for these.
Hyper Bandit: Yeah. Okay, it it. Yeah, I think we have the result four here.
Metal Taco: Okay, so good. You found all the islands, but now you need to figure out which ones are different.
Hyper Bandit: Okay. It. Okay, that would be a different question, I think.
Metal Taco: Yeah. Remember I said we wanted the unique island, so you're looking for the shapes. So you've effectively counted that there are four islands, but you need to show that there's two that look the same. So you really want the number three as your result.
Hyper Bandit: Okay, all it's it it.
Metal Taco: What are you thinking right now?
Hyper Bandit: I'm thinking that right now thinking that I can get all the top left cell of each island into like into a list. Then I try to. Wait a second. Unique shape it.
Metal Taco: So when I use the word unique or distinct, does that prompt any thoughts in your mind?
Hyper Bandit: I was thinking of like using hush set or something like this.
Metal Taco: Okay, great. That's great intuition. So you need to find something that you can stick into a set that represents an island.
Hyper Bandit: Yeah, but the question now is how to put the shape to a set.
Metal Taco: Right. Okay, that's fine. That's the problem you need to solve now. So how do you represent a shape in a way that you can put into a set? You know how sets work generally? How do they eliminate duplicates? What's kind of the standard type of set you might use in Java?
Hyper Bandit: Standard type for what? For shape.
Metal Taco: Standard set implementation sets an interface, but you usually instantiate a particular type of a set.
Hyper Bandit: Yeah, I think I want to use hashed.
Metal Taco: Okay, great. So you need an object that you can hash, that you can have a unique hash associated with it.
Hyper Bandit: Yeah.
Metal Taco: So what kinds of objects in Java do you know that are easily hashable?
Hyper Bandit: Like integer or string? Okay, I think it's integer.
Metal Taco: Yeah. Well, an integer is already just going to be some value that's going to be kind of unique. But you can hash a string, so that's great. Let's talk about, see if you can create a string out of this island shape somehow. How are you determining the island shape?
Hyper Bandit: Like how many rows they have and how many items in one row and they have to be in the same position.
Metal Taco: Okay, that's great. Well, let's just look at your actual code, which I think you have basically your helper method starting on line 55. That's how you're navigating the island recursively, right?
Hyper Bandit: Yeah, 55.
Metal Taco: By the way, I know you just called it helper method. Is there a standard kind of algorithmic name for what you're doing there? Particular search?
Hyper Bandit: It's BFS, I think.
Metal Taco: Okay, so a depth first search, right?
Hyper Bandit: Yes.
Metal Taco: Okay, now let's take a look at this method. If I were to give you the same island, like say you start in the upper left and you navigate that island, and then there was the one in the third column, I think third or fourth row down? Yeah, third column, fourth row, that's the same shape, would you navigate that island in the same order?
Hyper Bandit: Yeah, I think for this two, I over navigate in that same order. But.
Metal Taco: You'Re always going to check the I minus one first and then the I plus 1 second, J minus one and then the J plus one. So for any given set of islands, those orders are predictable so all you need to do is kind of keep track of which direction you move when you're going through recursion and throw that into a string somehow.
Hyper Bandit: Okay, string.
Metal Taco: Let's take a look at line 58. You're checking I minus one. What direction does that represent?
Hyper Bandit: Up. It's checking up.
Metal Taco: So you could maybe add the character U for up or N for north or whatever you want it to a string.
Hyper Bandit: Okay.
Metal Taco: And then the same thing for the other.
Hyper Bandit: Okay, I get it. I would like, sure. We'll need, okay, so I would like, when I move, I would like for here I will add one more input string s. And whenever this is movable before I go in, I will let this s to have U means I move up.
Metal Taco: Okay, that's great intuition. Let me ask you a quick question. Are strings mutable in Java?
Hyper Bandit: Mutable.
Metal Taco: If you pass string as a parameter S and then I just do S plus equals, does that actually do anything?
Hyper Bandit: I think they are mutable.
Metal Taco: Okay, so they actually are strings. You cannot change a string once you create it.
Hyper Bandit: Okay. I cannot change a string.
Metal Taco: Right. So there are other structures that you can add characters to.
Hyper Bandit: Yeah, I can use a string builder.
Metal Taco: Okay. String builder is a great idea. So maybe you pass a string builder.
Hyper Bandit: Okay. It will be called a string builder. And I will like for the other four, I would like to put it into the input it it. And for the other two I'll just have left. Well this is down and this is left. This is right. Okay, so now we'll have a string for each island and I will have to create hashtag of string it. Once we have little one, I would like stream builder into it. This I think. Yeah. And then I will just return the need for the count. I will just return the size for hash set.
Metal Taco: Okay.
Hyper Bandit: Yeah, I think this may be a word.
Metal Taco: All right, you're getting close. If you run this, you're going to get the number two. But see if I'm right.
Hyper Bandit: Okay, I'll try it.
Metal Taco: You got the correct answer there. So I'm, I may have been wrong with my guess, but let me see. Yeah. Okay.
Hyper Bandit: You want to try some other test cases?
Metal Taco: Well, I think it happened to be the order that you did. The up, down, left, right. That made a difference. So yeah, that actually worked if you had done left, right, up, down in a different order. So do me a favor here. Go down in your line, 60 through 71. So those first two checks for up and down and copy and paste them after your left and right checks.
Hyper Bandit: Okay.
Metal Taco: Yeah. So logically that should still work with your code, right?
Hyper Bandit: Yeah.
Metal Taco: All right, so now run it and see what happens. Okay. All right, here's the problem that we have, and it actually might be good. There are some certain shapes where.
Hyper Bandit: If.
Metal Taco: You take a look on line 21, so you see the two shapes in the right hand side. One, you go to the right and then you go down. And the second one, you also go to the right and then you go down.
Hyper Bandit: Yeah. Okay, I get it.
Metal Taco: Those would show up as RD as your springs. And so I'm a little bit confused why they're not.
Hyper Bandit: Okay. So I think I need to. I can, like, in my helper function, I can add a knob to the condition y face of zero question.
Metal Taco: All right, so basically, yeah, add one more character. So, yeah, there's a certain sequence of left, right, up, down, which would have given you the answer, too, is the bottom line.
Hyper Bandit: Yeah, I think. Yeah. Okay. Right. Oh, I get it. If I put going live first, I will have a two, I think. I want to check it out. Okay. I don't know.
Metal Taco: The reproducible failing test case here is if you go right and then down in that order, which it looks like it should. I don't know why it's working for you, actually. That's kind of funny.
Hyper Bandit: Yeah. I also think, yeah, it shouldn't work, but it worked.
Metal Taco: There's something weird. But anyway, there's some reason it's slightly different and it may be just how you initialize things or something, because. Yeah. Those should both show up as write down. All right, well, anyway, I bet if you output the set. If you print line the set, it'll give us some insight. Here I am debugging why your code is working. That should not be that way. Recognizes the problem.
Hyper Bandit: Just.
Metal Taco: Should just be able to online 50, line 54. Just do a print line of the result. Two string.
Hyper Bandit: Yeah.
Metal Taco: Okay, so there's a definite problem here. You're going down one and you're never going right. There is a bug it. That's the one where you go down first.
Hyper Bandit: Then righteous it.
Metal Taco: I'm wondering, your I's and J's might be switched. No, yOu're going down first. A plus one's. Oh, I see it. You're doing map length. You only have six rows in map, but you have seven columns. So your check condition on row 61 should be.
Hyper Bandit: Yeah, I thought that was name no off. Yeah. Wise.
Metal Taco: Probably the same as your l there on line 44.
Hyper Bandit: Yeah. Right. Okay. I think now it'll be. Have the bug, we think. Yeah, now it's two okay.
Metal Taco: There you go. There you go.
Hyper Bandit: Okay, so we can fix by.
Metal Taco: You made your W the same as your l, though on line 44.
Hyper Bandit: W.
Metal Taco: I swear you did that earlier. But yeah, that was right. Okay.
Hyper Bandit: Yeah. Okay. So I need to put some more characters in it when it's not what I think. Ef zero. So if it's not like append some work and like it.
Metal Taco: Okay, let me stop you right here and tell you this is not going to work because it's going to behave differently in the boundaries than it is otherwise.
Hyper Bandit: I don't think it will happen by. If. When we check.
Metal Taco: Your two RDD shapes, the one on the is not going to be able to go to the left, so it'll fail. The I minus one or the J minus one condition.
Hyper Bandit: Yeah, I get it.
Metal Taco: Just depend something at the very beginning before you do any of those.
Hyper Bandit: Cool. I get it. When I do every loop, I can like. Yeah, you're right. I can just append like this is like loop one kind of thing maybe like.
Metal Taco: Honestly, I think any character there will work.
Hyper Bandit: This is clear. Yeah. You don't think this kind of works?
Metal Taco: Well, as you're doing, it'll work, but I think you're over engineering it. I think you could just put a space there or any character other than L-R-U or D.
Hyper Bandit: Good. Okay. I can just add a character here.
Metal Taco: Yes.
Hyper Bandit: Let's try it. I don't think this works still. Give us.
Metal Taco: How come you're not. Okay, so maybe I was wrong here. I'm trying to think. Do it your way.
Hyper Bandit: It add the index, like the row number and column number into it. I think it will solve the question.
Metal Taco: Yeah, actually, I think maybe rather than doing at the beginning, if you did at the end and said, hey, I've looked all the four different directions. No, you're always going to end up at the end.
Hyper Bandit: Yeah, we always do. Just like it.
Metal Taco: No, that's fine.
Hyper Bandit: Oh, no, this is not good. Okay.
Metal Taco: You were doing before.
Hyper Bandit: Yeah.
Metal Taco: Because on one of them you would be doing on the first level. On another one, you'd be doing on the second level.
Hyper Bandit: That's it. Just user looks it.
Metal Taco: There you go. I think that will probably work.
Hyper Bandit: Yeah, it.
Metal Taco: All right. Excellent. I think you got it there.
Hyper Bandit: This is an interesting question.
Metal Taco: Okay, great. So let me just ask you a couple of questions about this, the standard ones. What do you think is the computational complexity of this code?
Hyper Bandit: I think the time complexity would be. The time complexity for loop would be O N squared. I think that's the large time complexity. And the space is also O N squared.
Metal Taco: Okay. So when you say N squared, you've got a matrix with rows and columns. So which one?
Hyper Bandit: Yeah.
Metal Taco: So order of M times n is what you're saying.
Hyper Bandit: Yeah.
Metal Taco: So how about the searches themselves? Is that included in your calculation or how would you factor for that?
Hyper Bandit: The what? Sorry?
Metal Taco: Well, your, your helper function.
Hyper Bandit: Yeah, I think I. Oh, I mean.
Metal Taco: So we know you're going through the entire array once to look at every square once. Then the question is, are you more often than that or not?
Hyper Bandit: Yeah, I think. No, I think include helper function, it will be like M squared Times N square.
Metal Taco: Okay.
Hyper Bandit: And the space complexity will be think be at.
Metal Taco: Sounds good. I think we have about nine minutes left and there's usually about five minutes for feedback. So we don't really have time to jump into a new question. But I think we've kind of beat this one to death. So let's just go ahead and end here. I'm going to offer you, if you want, I can give you some real time feedback, or I also want to just give you, I'll be giving you written feedback afterwards. So if you'd prefer to just ask other questions right now, you can feel free. I'll just give you the rest of the interview time to ask any questions you'd have. Or if you'd like some verbal feedback right now, I can give you that as well.
Hyper Bandit: I would like some feedback right now.
Metal Taco: Okay, wonderful.
Hyper Bandit: Yeah.
Metal Taco: And I'll follow this up, written aNyway. But I can give you a feedback overall. You did really well, I will tell you. I'm going to mark down your communications. And the reason for that, it's not necessarily verbal communications. A lot of it is just like the variable name and that kind of stuff. And everyone likes to use I's and J's. And that's great if you're just counting things. But when you're actually representing something physical, like a map of an ocean, it would be good to use directional things like North, south, east or west or rows and columns or things other than INJ. So even right now, after solving this with you looking at your code, if you asked me, is I the row or is I the column and is J the row? Is J the column? I would not be able to tell you that off the top of my head. Do you know that off the top of your head?
Hyper Bandit: I know, but I know it's confusing.
Metal Taco: So there you go. Obviously, single variable letter names are fine, like L and W for length and width were great. But when you get to inJ, then it starts to get a little bit more confusing. So just something to think about. Verbose variable names are always good. Verbose method names are good. Like you have a count island method. That's great. And then you have this helper method. Well, yes, I know it's a helper, but I prompted you and asked what sort of a method is, and it took a little bit of questioning to see it was a depth first search method, right?
Hyper Bandit: Yeah.
Metal Taco: So naming it DFS would have been a little bit better. And again, this sounds like Nitpicky, but in an interview environment, you want your interviewer to understand exactly what you're doing. Actually, in a real world coding environment, you want to write code that is very clear. And I often see very long multi word variable names in production code because you kind of want it to be self documenting. And what's on there, that's kind of one of those key feedback points I want to give you. It'll help in an interview if the interviewer understands what you're doing as well as in production environment. I did have to prompt a little bit about how are you going to remove duplicates, and we talked about string immutability and stuff like that. So that's kind of a gotcha, especially for Java. Definitely know what you were able to quickly say, hey, let's use a string builder. And that's great. Knowing string builder exists is a big plus. So that shows you know a little bit about the language, but do have an idea of when you pass a variable in an argument that you're not going to be able to modify it like the way you did loop is fine because you're not expecting loop to be returned, but when you initially wrote your code, you eventually deleted it, so it didn't stick there. But initially I think you were passing count around as a variable or something like that, and that would not have worked. Fortunately, you deleted it. But just an idea of what happens when you pass an argument to a method, knowing which objects are mutable, primitives and strings are not mutable. So when you pass them to a function, you're not going to be able to change them. That's where you go. A big plus for you. And it may have swung you from the almost failing to, hey, you're going to pass is when I pointed out that there was a problem in your code. Even when you got the right answer, you did not give up. You're like, okay, I got to figure out what's wrong with my code and fix it. And that impressed me. So great job doing that. You didn't say, well, it's right, I'm getting the right answer. You realize that right answer for the wrong reason is not appropriate, and you dug in until the two of us found the problem together. So great job there. And I even suggested, I guess, probably a wrong solution to the problem. And you got a better correct solution by passing that loop variable, which is what you're going to do to begin with. Before I said you were overcomplicating it. So I do think there's an easier solution, but I'm not sure that under the time constraints of this interview that we would find it. Great job there. So, yeah, you did a great job. A little bit of prompting required, but that's just nervousness or trying to think under pressure, but with a little bit of prompting and you didn't give up and you went after things. The only thing I would suggest is just be a little bit more clear on variable naming or use comments or do other things just to make it easier for the interviewer to follow along where you're going.
Hyper Bandit: Okay, cool.
Metal Taco: All right, that's it. Any other questions you have for me?
Hyper Bandit: How would you rate the question? Is it a medium question or easy question?
Metal Taco: It actually is on lead code somewhere. I think it's called Count unique Islands. I think you have to be a member to have access to it, but it counts as a lead code medium. It's a lead code medium level question, and those are the level you're going to get on your interviews. Easy is really too easy. As a software engineer, you're not going to get easy, and then hard is going to be too hard for you to answer in the space of an interview. So they're not going to give you that one either. So you're going to get lead code, medium level questions on your interview. Have you ever heard of the site neatcode IO?
Hyper Bandit: Yeah, I heard it.
Metal Taco: Yeah. That is a great site. Obviously, knowing how to do all the lead code is great, but there's no way you can do all the hundreds of those things. That site really boils it down to, I think there's like a blind 75 and then there's an additional neat code 150 or something. Those are great because they cover all the different types of things. Again, don't just work to solve the problem, but understand the solution, understand why you got that solution. What are the different ways to solve that problem and why didn't you do it? I used to ask if you remember two sum, it's a lead code, easy problem, but there's, like, three different ways to solve it. And I used to ask that one, and I would tell people, okay, solve it all three ways. And that kind of turned it from easy into hard because you kind of had to think of all the different ways to do that. But just approaching it that way, thinking it in terms of it's not the solution that matters, it's how you got there. And what are the data structures you use and showing that you know about hash sets and hash maps and the fact that they're order zero lookups, and that's great. And all of just those types of things are what people are looking for. And throwing that out there during an interview is great. It's like, well, this would be really more efficient because I'm using a hash set, and that's order one lookup. Just throw that knowledge out there in your interview, and you show your command of the language and your knowledge of algorithms and stuff like that. So you definitely want to communicate that to the interviewer. All right.
Hyper Bandit: Okay, cool. Am I supposed to solve two questions today, not just one?
Metal Taco: Well, this was sort of two questions. It was Account islands, and then account unique islands. So sometimes you get to two questions if you solve one super fast. In our case, we did some debugging work, and we explore some great things during that debugging. And that kind of counted as your second question. If you had solved this super fast, I would have given you a more challenging second question. And I have a stumper that always stumps everybody, so don't worry about that happening. Interviewers like to push you until your breaking point. So if you solve something great and then they give you a really hard one, and then you fail, it may not be a failure. It's a testing your limits and seeing what you do when you don't know how to solve something, that's a good thing. When it happens in an interview.
Hyper Bandit: If that happened, I should just talk about what I'm thinking to solve.
Metal Taco: Always talk about your thinking, your problem solving approach, just any intuition you have. If you hear the word unique, you should immediately saying, oh, this means a hash map or a hash set. That's kind of your knee jerk reaction should be something like that. And when that comes up in an interview, you'll think that if you have a matching parentheses, matching problem, or palindromes or anything like that, you should think, oh, this is a stack based solution. So I'm going to be using a stack in here somewhere. I don't know where yet, but something like that and that's kind of where the neat code problems will help you out. They'll say, oh, this is the right time to use a depth first search. This is the right time to use a stack in those kind of unique data structures. And one more data structure, if you haven't learned it yet, is a try. Make sure you know how to use that. There's a boggle problem. If you haven't solved that, solve boggle. That's a very helpful problem.
Hyper Bandit: Try map.
Metal Taco: What's that.
Hyper Bandit: You said? Try this one.
Metal Taco: Conceptually, it's nested hash maps. So you can have a map where you look up a map inside that. It's used for file paths or rest paths or a lot of path based things where you can get a really fast lookup. That in combination with a breadth first search or a depth first search gives you a really great caching mechanism to look things up faster the second time around. So the canonical example is the classic boggle question. Where you here? I'm just going to copy and paste. At the very bottom of our screen, I'm posting the standard question. They give you a boggle board where you try and create words and you're going to have a dictionary. And if you're just doing a single version of that, you can just do a depth first search and find the answer. But what makes it interesting is if they say, I'm going to give you a very large number of words, a whole dictionary of words that I want you to check, then you want to store your partial solutions along the way, and that's where you want to use a try.
Hyper Bandit: Okay.
Metal Taco: All right, great job. Great talking to you, and best of luck with your interview.
Hyper Bandit: Thank you. Thank you very much.

We know exactly what to do and say to get the company, title, and salary you want.

Interview prep and job hunting are chaos and pain. We can help. Really.