Black Friday sale! Get $500 off on 10-session dedicated coaching.

Watch a technical mock interview with a FAANG engineer
Flannel Artichoke, a FAANG engineer, interviewed Ghost Koala in C++
Share
Summary

Problem type 

Longest non-repeating character substring

Question(s) asked 

1) Given a string, return the length of the longest substring that does not contain any repeating characters.

Feedback

Feedback about Ghost Koala (the interviewee)

Advance this person to the next round?
  No
How were their technical skills?
2/4
How was their problem solving ability?
2/4
What about their communication ability?
3/4
Overall, when the interviewee is in the interview, he/she should always keep this in mind - the purpose of the interview - collecting data point for hiring decision. Interviewers are supposed to collect data point from the candidate, and candidates are supposed to provide data point. Most candidates just rush into a given problem and try to provide a solution, but that is not an ideal approach to get a win! -------- During the interview, the interviewee was good at implementation and quickly finished the coding part without any issue, but failed to come up with the final optimal answer, which is a minus for the final decision. Not every interview requires the right optimal solution to given questions, but for this interview, the expectation was getting the final solution in a given time and moving to the next question discussion as the difficulty of the problem isn't extra hard. Regarding a problem solving skill, I think there is a room that the interviewee can improve more, especially at validating solution idea with own test cases before jumping into implementation. The given problem has many known optimal solutions and very typical string match problem, but also many people actually miss edge cases and end up confusing themselves during an interview. During this interview, the interviewee could have taken more time to think about edge cases. About communication skill, I would give 10/10 score for him. He was trying to share his thought and didn't hesitate to ask a help to interviewer, which is great. He also demonstrated being pretty flexible on changing his direction based on interviewer's feedback during the interview too. In summary, the interviewee was very close to 'inclined to hire'. If he can improve the above, I think he could get a good result in real interviews.

Feedback about Flannel Artichoke (the interviewer)

Would you want to work with this person?
  Yes
How excited would you be to work with them?
4/4
How good were the questions?
4/4
How helpful was your interviewer in guiding you to the solution(s)?
4/4
N/A
Transcript
Flannel Artichoke: Hello. Ghost Koala: Hey there. Flannel Artichoke: Hi. How's it going? Ghost Koala: It's going well, how are you? Flannel Artichoke: I'm good. I'm good. Thank you for your time. Ghost Koala: Yes, you too. Flannel Artichoke: Yeah. So I'm Alex. And I'm currently working for the one of the FAANG company for more than five years as a back end engineer. I'm joining this interview as your interviewer. And I'm gonna do the same thing exactly what I'm doing for current company as interviewer. So basically, the bar is the same. Ghost Koala: That sounds good to make perfect. Flannel Artichoke: Sure, sure. Let's start then. Can you briefly give introduction about yourself? Ghost Koala: Yeah, sure. So my background. Go ahead, please. Yeah, so my name is Wolfgang. I'm, you know, 10 years in the workforce. I graduated in 2011, with a master's in mechanical engineering. And, you know, my career trajectory has been entirely in the manufacturing space to now actually, I'm a product manager right now. But I've also been doing a ton of programming. I've taught myself a lot. And I'm currently working on transitioning my career out of manufacturing into tech. And then kind of what brings me to this platform here. And the mock interview, is I'm interviewing with Google, actually, I'm interviewing with a few companies, but the kind of most most excited that I'm about is interviewing with Google. I have a virtual onsite on Tuesday, and I'm just trying to, you know, do the best that I can to prepare for that. Flannel Artichoke: Right, it sounds good. Ghost Koala: Okay, so let's just get started in this intermediate like algorithm interviews, I'm going to provide an algorithm question for you, so you can take a look and solve the problem with me. That sounds good? Flannel Artichoke: Sounds good to me. Yeah. Ghost Koala: Right. Um, do you know, the concept of subsequence and the substring of a string? Flannel Artichoke: Subsequence and substring of string? Ghost Koala: Yeah, yeah. Flannel Artichoke: I mean, yes, I guess I'm familiar with the concept. Sure. Ghost Koala: Can you explain the main difference between the two? Flannel Artichoke: Okay, so a subsequence will be any number of characters in order as they appear in the string, but not necessarily contiguous. Whereas a subsequence will be a set of characters in the string that are contiguous. Ghost Koala: Right. Sounds perfect. Right? Let me copy and paste in my problem in here. Can you see my problem? Flannel Artichoke: Yes, I can. Ghost Koala: Sure. Please take your time to the understand. And you're basically free to provide any example to go over with me. Flannel Artichoke: Sure. Okay. So let's see, given a string as find the length of the longest substring without repeating characters. Okay, so yes, your point. Let me see if I can put in a few examples here. You know, it's not letting me make any changes to see if I can now right? Yes, now I can. Okay, so a few examples. So let's say we have ABCDEFG. So this would be s. So in this case, given a string asked find the length of the longest substring. So the answer here would be one, because there's no substring here that's longer than a length of one. Maybe ramping it up a little bit. Let's say we had aaaa BBB CCddd. So here we have a few different substrings of varying lengths. A has a length of four, B has a length of three, C has a length of two, and D has a length of two. So here the answer is four, because A is the longest substring at four. Ghost Koala: No, I think if you go to like the problem itself, I can't like we dealt repeating any characters. So in this in your second example, the answer, maybe maybe. Yeah, okay, length is going to be two. Flannel Artichoke: Okay. Okay. I see what you're saying. So here 12345123. Ghost Koala: And the answer for the first example, would it be seven? Yes, that's right. Flannel Artichoke: Yes, you're right. And here we have a B has a length of two BC has a length of two c, d has to satisfy them. Okay, got it. I misread the question originally. So I'm glad we did the example. Okay, yeah, I think I think that probably makes sense to me. So let's see, I guess in terms of how I want to go about solving this. Let's think about this. So I guess the first thing that comes to mind is, you know, starting with an iterator or I guess a pointer to the first character in the string and then... Actually, maybe I want to have them, I want two pointers, one to the first character went to the very second character. And then that way, I can compare two characters that are side by side. And that just keeps incrementing. The so both these pointers will be right next to each other the whole way. But it'll let me compare when two characters are the same, or the not or not. And if they're not, I can increment a counter until I get a repeating character again. And then that counter, I'll kind of keep the max of that counter as I'm going to the string and then return that max at the end of the function. So that that approach seems like it should work. You know, that would execute in so because I'm just going through the string once that would execute an O(n) time, and the space complexity be constant, because I'm not using any extra data structures. The one thing I want to the one kind of gotcha I'm going to want to look out for is, you know, if there's any sort of overlap, like I don't want to accidentally count something as repeating when it's not accidentally when it's not actually repeating. So I'm going to want to make sure, you know, maybe using both of these inputs through the, through the function, burn those test cases, just to make sure that they actually work the way I'm expecting them to. Okay, so does that general approach make mostly sense to you? Ghost Koala: Yeah, that makes sense to me, and do wanna go over more advocated, like, why they are like, two, longest substring? In a given scene? What would you do for that? Flannel Artichoke: Yeah. Okay. So you're asking about the edge cases? What was what was the last part of that question, though? Ghost Koala: What are the two longest substring in a given string? What would you do with that? How they? Um, so Flannel Artichoke: You're saying, What if I was asked to find the two longest substring rather than than just the one? Right? How would I do that differently? Yeah. That's a good question. Well, so I guess the the approach I was talking about, where I'm incrementing a counter, and then returning the max of that counter, I suppose. Yeah, I suppose what I could do is instead of, instead of only keeping the max of that counter, I could just keep the I can keep the total, like, anytime that counter resets, I can save that amount. And then in let's say, like a vector. And then after I'm out of that, after I'm done looping through the entire string, I can return, you know, the the top two values in that vector. Ghost Koala: Interesting, right. I mean, they can't they kind of make sense to me. All right. Flannel Artichoke: And then in terms of other edge cases, that guess the best I could think of is, if you give me a string with a single character, then my approach is going to fail, because I can't, I can't have two pointers when there's a single a single character. So in that situation, so really, I just have to check that at the beginning of my function. If the string is a single character, then we can logically deduce that the longest substring without repeating characters is one because there's only a substring of one, so we can just return a value of one. And then for anything greater than one, then pretty sure the approach of laid out should work. Ghost Koala: Makes sense to me. Right? So it's good. And let's start coding. Flannel Artichoke: I think I do. I guess, first of all, though, in terms of inputs, are there any restrictions on the length of the string as or should I just assume that it's, you know, arbitrarily long? Ghost Koala: Ah, you can just say, it's just a reasonably long for sure, you don't even have to him like the the last topic of listening. Is it too long or to limit too long? It doesn't happen. Flannel Artichoke: Okay. Yeah. So it'll like fit in memory. And yeah. Ghost Koala: Exactly. What about that? No, yeah, that's not the point of the scene. Flannel Artichoke: Gotcha. Gotcha. And then I guess, along similar lines, do I have to worry about I guess, what types of characters or what types of encoding is coming in here? Or should I just assume that you know, every character will, you know, let's just say UTF eight, and that I don't kind of have to worry about the different encodings and maybe double wide characters? Ghost Koala: A lot of oh, we are we have, we add like frontend the validation about the cable characters only retain the alphabet like a to z and such. Yeah. Flannel Artichoke: Okay. Good. Good. Okay. So that does make it a little bit more simple. Alright, so I'm going to come up here and you want me to return the longest substring the length of the longest substring so that'll be an integer. And then what do we want to call this thing? How about the length of the longest substring without repeating characters? Longest substring without repeating. It's a bit verbose, but it's at least, at least descriptive of on what we're doing here. And then here, we're going to have a standard string, which is our input. Alright, so the first thing, we'll go ahead and handle this edge case that we were talking about. So that if the length is equal to one, we're just going to return one, because that's the only substring that exists. So the next thing I'll do is I'll create the two iterators that I talked about, I'll call them head and tail. So this will be messed up again. And then what I'm going to want to do is I'll iterate until the tail pointer gets to the end, so while tail is not equal to that end. And then I'm going to go ahead and put the increment down here, because I don't want to forget to do this. Otherwise, my loop is going to be infinite. Okay, so the next thing we talked about doing was keeping track of our max substring without repeating characters. Okay, and then I'm also going to have to have int. So this variable curl, this is transferred to the shorthand for current. And this will be kind of so max will be you know, as I'm checking each substring, without repeating characters, if I find a substring, that's longer than max, I'll update max. And then I'll reset current back to zero, because this will be the actual working set that I'm working on. This will be what I end up returning, in fact, go ahead and add that to the end of the function here. Alright, and then so here, what I want to do is if... So if the two characters are the same, that means they're repeating. So that means I have to start over. So that means current gets reset to zero. And max gets equal to current minus one. So one thing I want to do here is double check if I need to subtract one. When I go through with the with an example, I'll double check this, but I'm pretty sure because I'm incrementing down here, and then checking up here that the actual length will be minus one, but I'll just leave this for myself to check once we're going to the test case. If they're not equal, then this is where I'm just going to increment this, the length of the current substring by one. And then I'll keep going until I find two that are equal and then update the max. All right, is there anything else in the check? This will exit when I get to the end? Okay, I think I think that's it. Why don't we go ahead. And unless you have any questions on what I'm doing here, I kind of wanted to go ahead and just run these two examples through through this algorithm just to kind of check how it works. Alright, so what I'm gonna do, I'll use these markers, I'll use carrot for the head and just kind of this right, right arrow for the tail. So when I first come in here, the size is not one, so this doesn't hit and then my head gets initialized here on the A, the tail gets initialized on the B. And then the next thing that happens is if it's head equal to tail, they are not equal. So now current gets incremented by one, so let me kind of keep a running total here, current is equal to one both get incremented once, so this is going to go both move to the right, B does not equal c, so this will get incremented to two now. And then they'll both get moved to the right again. C does not equal D. So that will now go to three. Okay, and this condition while tail does not equal, and that's not going to happen until we get past the G so we're still good. So we'll go again, D does not equal e so this will go up to four. Do this again. He does not equal f this goes up to five to more f does not equal g so this will go to six and then finally... Okay, so this is awkward. So really, this check should be minus one. Because the tail we added the one here that right now that's not right. This is right. So now the tail is equal to end. No, okay, yeah, do the minus the reason I need the minus one is because I'm checking the value of tail here. And if I check it when it's equal to end, and that was right. So I got down here, I got to end. And now I'm taking the while and now it bails out. So this is right. So once I get to the G here, nothing else executes. So now returning six, which is not really the number I wanted. So the question is, why is it not the number I wanted? Okay, it's because I think this should start at one actually. Not zero. And let's kind of think through that real quick. I'm going to make one more example up here that's only got three characters in it. And in this example. Yeah, it's because I'm checking two values at the same time. What if it's only two characters long. Yeah, I'm checking two chars at the same time. And so I've already checked for the instance where my carrot where my string is one long, in which case I have a substring of one. So it seems like... Yeah, I can't have a substring of zero. That's why I'm always gonna have at least a one here, I'm always going to have at least a substring of one character, which is why I need it initializes at one instead of zero. So if I do that, and I rerun the string through there, then this will end up being seven instead of six. So I feel pretty good about that. That makes sense, or was that a little bit confusing? Kind of how it jumped back there? Ghost Koala: Well, I think that makes sense. Flannel Artichoke: Does that make sense? Okay, so now let's go. So that was kind of a simpler case, maybe let's go through this one with the repeating characters and see if we can get the right answer still. So in this case, again, it's not equal to one. So this first check here does not hit. Instead, we initialize our pointers at a and a, and here since they are equal to each other, so head equals tail, max equals current max. So here's... Okay, so here we're checking this, do I need to subtract one? Think the answer now is no to the question attract want to end up with a zero. And that's not what I want it. So let's go ahead and remove that note. So now I'm just resetting the max to the one, this one, this is going to repeat a few times actually. So let's do this current equals one. And that same thing is going to happen when I get to here and here. And then finally, I'm going to get to here. So here I have an A and a B, these are different from each other. So now this conditional no longer hits, and instead I'm going to increment current by one. So let's increment this to two. I'm going to go through again now the two B's match. And so now my max is going to update to two. My current will reset to one. Here current is still one here, it will go to two again. And then the next time here it'll reset max to two again, just want to go to one. Good. Here, Okay, this one's interesting. So here, will, Max. Okay, that's good. I'm glad we're checking it. So here we only want to update max if current is greater than max. Otherwise, it's just it's not going to be the right number. So here now because of because we've added this conditional this will this current will not override this too. So now we still have a two in there. Here we get back to the DD actually this is when the check occurs. And then finally, we get to the end and then we bail out because now tail is equal to end. Okay, yeah, I think I think that gets it done. Ghost Koala: So maybe we can compile and it's good. Your function with this editor say VS code down to line number 48. We can just delete the current one and the usual function with the more examples. Flannel Artichoke: Sure. So let's see. Did you have any particular examples in mind that you wanted me to run this on? Ghost Koala: You can maybe find more in other cases. Flannel Artichoke: Okay let's try that what did I call this thing? Longest substring... Okay, so that's one example. Ghost Koala: Maybe you want to try some different patterns in your example, like, patterns? Like ABC, aa, MPDF, something like that. A, B, C, C, then ABCD? Flannel Artichoke: Yeah. ABCD ABCD. Okay. Now you got me curious. Well, so I can run it. Like you're suggesting, or I can I can walk us through that example. To see kind of what happens. Ghost Koala: Yeah, then you can just run it first. Yeah, we got an error you can see or expect. It's like a simple error. Flannel Artichoke: Yeah. Okay, so I got two and then I got three. And we had a space in here too. Ghost Koala: What do you think about the second result? Is it correct? Flannel Artichoke: It's not because it should be. Let's see, I got 123. It should be a three here for the ABC. You're out here have another three for the ABC. But instead we got... Oh, no, that is the three. I got three. I'm not ABCD, that's four more. Ah, okay. So why did we get that is because this last one is not being counted as part of the substring. You're right. So that is an edge case that I'm not dealing with right now. So how can I deal with that edge case? Let's see. So once I bail out of here so I can add a one here at the last two characters? Ghost Koala: What about B is not the end of the thing. What if we have like more characters like double E, F, G, F to even have to be to the right. Flannel Artichoke: Like this? Ghost Koala: Yeah. Flannel Artichoke: If we have a double E there? Let's see. So here, I would count one. This would increment it to three. Ghost Koala: This would increment to four. Why don't we kind of walk through this example up here. Flannel Artichoke: So in this case, I do like this. Let's see what happens. So current starts at one. And then I have my head pointer here and here. So those two are not equal. So then I increment to two. That makes sense. Here, they're still not equal to the increments of three here not equal. That increments to 4. 1234 here, so I do have here still not equal. So that increments of five still not equal to six. So now that they are equal... Current is greater than max, max will be six. So this, in this case, it seems to work as expected. But if I drop one of those E's it does not because here I bail out. And I don't add, or I don't update. Okay, so I think what I need to do here is at the very, after I get out of this loop, I think, whoops. I think I need to check this one more time because I already updated account, but I didn't get a check. I didn't get a chance to run this check, because I went past the end of my list. So I think this should fix that edge case. Yeah, what do you think about that? Ghost Koala: Well, um, let you get and see the result. Flannel Artichoke: Okay. Let me go ahead and add a space in here. And over here. Then, so here, we got the two that we expected. Here we got a B, A, B, C, D, E, five, but on us C, A, B, C, D, E, that's six. So that is right. So that that did give me the right substring there. Ghost Koala: Why is the right answer? Can you point? Flannel Artichoke: Excuse me? Ghost Koala: Why six is the right answer for the second case. Flannel Artichoke: So here, if I start with a second C, then I have C, A, B, C, D, E. Ghost Koala: So then repeating the right. Flannel Artichoke: It's repeating, but they're not consecutive. Is that? Ghost Koala: Yeah, no, no. But still, yeah, the longest substring has two things there, which is not the right answer. Right. Flannel Artichoke: Oh, the longest substring. Okay. So the longest, man. Okay, so I was completely misunderstanding this repeating. I thought it was consecutive. But there should be no repeating characters at all in the substring. Ghost Koala: And I think that doesn't know that you mentioned that consecutively repeating in the question itself, right? Flannel Artichoke: You're right, you're right, I just made that assumption and never validated that assumption. So now I have to check for repeating characters. So that's going to change my approach a little bit. And it's also going to change the complexity. So what I can do now, I think, the, the main bones of this approach should work except I have to add another check now. So what I'm thinking of is keeping a hash set, or I guess in. In C++, I'd be like an unordered set of all the characters I've seen so far. And when I find one that repeats, I'll store that length as my max here. And reset it to zero and D it out. And then keep going. Ghost Koala: Why did you think with the hash table, it is question? Can you a little bit complain about your thought process a little bit? Flannel Artichoke: So a hash table more more of just a hash set. So or a unique, I guess, a list of unique values? Well, and the reason being that I can, I can look up the values in constant time there. So it's not going to be too, too much of a time penalty. And each time I hit a new character in my string, I can check if I've seen it yet. In order to determine whether or not I have a repeating character, I guess the main issue I'm thinking of with that though. Okay, so I guess that's actually not going to be that great. So I'm down here on line 68 right now. So the main issue I'm seeing with that is, let's say I start here with a, so I put my I'm a little guy there, and then I check B and then I check, C, D. A here. Okay, so that that approach will work and now that'll return 1234 that you're talking about? I couldn't get that length before. But now what I'm going to have to do is go up to the V here and reset this pointer to the C and then go again. And doing that approach is going to have now, O of n squared complexity because I'm, you know, in the worst case, I'm going to have to go through essentially, this whole list twice. Ghost Koala: Each wire for the length of this substring, right from BCD. And why you have to take iterator again from the beginning for which it is B. Flannel Artichoke: Why do I have started? Why do I have to be instead of starting over here at the end? Yeah? Ghost Koala: Yeah, that seems like it's redundant to me. What do you think? Flannel Artichoke: It does, but I mean, let's say... Okay, so for example, if I did that, then here, I would have eight E, F, G would be four. But that's not actually the right answer. Because if I started at B, I have I can go all the way to the end without any repeating characters. So my real answer is 1234567. Right? And that's why I can't start over here on the a rather, I have to start on the next character. In order to check if that's the beginning of a new substring with no repeating characters. Ghost Koala: Well, you know, the length of the substring always right, BCD. It's like a three and then not right. Now you're going to start with a which is next. A, you know what I'm saying? Flannel Artichoke: I see. Okay, so here. So here, I can like store three. Yeah. And then now when I get the rest of this, plus four, now I have the actual length. Right. Ghost Koala: Okay, that could generalize this approach more, but for more advocates, but I think you're on the right track. Flannel Artichoke: Yeah. Okay. That's a great hint, too. So, yeah, I think, I suppose I think using an unordered set will be helpful, because I'm going to do those lookups in constant time. This, we're going to be walking through the string, just want so that'll be okay. And so this, this looks pretty promising. So I think, I think I'll go ahead and how we're doing on time, we're running a little bit low. I'm gonna go ahead and try to implement that and see if I can get that banged out before right of time here. How does that sound? Ghost Koala: Sounds good. You can start. Alright, so I think you got 12 minutes wall. So still, you have plenty of time to implement? Flannel Artichoke: Okay. So let's go ahead and do I still give me my head and my tail? I don't need current anymore, because that would just be the size of my set. Okay, if Head Equals tail, so that I found a repeating character? Nope, that's not right. So now what I want to check is instead of if Head Equals tail, I want to check... check if I've seen this value yet. Because if I have then if seen that size minus one. And the reason I have to subtract, do I have to subtract one here? Let's see. ABCD? Four? No, I don't think I had to subtract one. So if my current unique list is greater than max, then update that don't need this anymore. Do I do need to empty this out? Take this out. And what I do is else otherwise, I'll insert that into my set, increment both of these. Alright, and now with this other thing that we had, we want to Okay, so the other thing I want to do is in well, okay, so in max equals seem plus size. So really what I want to do here try to think of how to like the three plus four thing. I'm trying to think of the right way to do that. So I wonder if I can just do plus equals size, but that won't work because I found a repeating character. Yeah, so I'm going to do this minus one. And then the last thing I'll do is add the final size of on the unique list. Ghost Koala: I'm not familiar with the C++ but is another that is a factor that, like, if you like insert three characters there and size of the scene is actually three? Flannel Artichoke: Yes. So if the contains three characters and the size is three correct. Ghost Koala: Then you have to make sure that you have to remove any repeating characters, right? I'm not I said I got it. Yeah, yeah. Flannel Artichoke: So the unordered set. If I enter a character that's already in the set, then it's a no op, it won't put it. Okay. Yeah. So that's kind of taken care of that for me. That's kind of the gist of it. But now Now what I'm kind of thinking of, and I'm, I'm gonna jump back down here to line 67. Because let's say there's another H here, h i, j, k l. So here I got my three. But then I found another substring here 1234. And when I get to here so this is where this approach kind of breaks down a little bit, because now I have another A. And I can't really add the three plus the four. I guess I can't, I guess I can always add it to the previous. Yeah. So whatever the, whatever the last unique set I saw was, I can take that minus one, and start and start adding to that. Okay, so this shouldn't be plus equals, it should just be plus. Man, I'm kind of confusing myself a little bit here. So here I came out 1234 ABCD. And when I get to the A, that's repeating, so I have the four. So I'll, so I'll take four minus one is three. That's what I'm doing here, max equals four minus one. And then start over, then I get 123. Let's add one more here. So here we go. 12345 with the cue being that size five is greater than four. Or should this be I think this should be the minus one here as well because that's where we're gonna end up updating it to see that size minus one because we found a repeating character and then keep going here 12345. And then we add the file size to that minus one. Okay, this looks like it should do what we're talking about. But I want to go ahead and actually walk it through this example here. And we do still have a little bit of time. So now I I could walk through this manually, or I can compile it and run it that way. I don't know if you have a preference. Ghost Koala: We can do both. Yeah, maybe we can compile the first. Flannel Artichoke: Compiler first. Okay, I can do that. Yeah, let me copy and paste the example here. Ghost Koala: You can add new lines for the use cases Yeah, copy and paste cool. Flannel Artichoke: Yeah that's not our case there it is. Okay. So let's try that. Onwards are expected P wise is expecting P. Ghost Koala: Is in like the library show that you can add a dependency like on those are the three at the top. Yeah, yeah, yeah. Flannel Artichoke: Thought it was already included. Maybe Cool. What is this warning? Solution comparisons. Okay, because this returns an unordered. And my max is int. I can fix that, I suppose. Ghost Koala: Or unsigned or, well, the warning is fine, but it seems like results are not the one that we expected, right. Flannel Artichoke: Okay, let's see. The right because we got a zero up here, we got another zero, and then down here. Today this is telling me the wrong substring here. Okay, so that looks wrong there. So for this one, it should be a 12345. So that last one looks actually probably right on to... show you. Why is it showing zero? Let's see. So let's see we start with the two A's. The A's keep matching. Okay, every time the A's matchup I see seen that size, which is zero. I can't subtract a one from zero. Can I have another scene that size should be you know, I should initialize seen with at least the first character first, and then here, I should re initialize it with had. I don't think that's going to fix our problem though. But it shouldn't. It shouldn't be empty, though. It should always contain at least one character that is at the head. Which is what what I just tried to do in there. That's still going to be zero though. Has no member I can't see the whole error. Oh has no member named first. That's fine. Ghost Koala: But the day maybe it is zero at the index. Yeah, yeah. Flannel Artichoke: Now we have a one that's a little bit better. But that's probably because we subtract the one here. So obviously subtracting the one will fix that. But then, like down here, we have an 11 on this last one. So man, this is really getting away from me. I'll tell you what. Ghost Koala: Alright, I think we've got one minute left, you can give a final shot and see if your thing is working. Okay. Okay. Flannel Artichoke: Okay. So yeah, that was I mean, yeah. So I mean, unfortunately, and I hate that I wasn't able to get it. Ghost Koala: No problem. I'm using this question a lot from my practice doesn't actually know your company. But surprisingly, a lot of candidates are actually failed to solve this problem perfectly. You know what I'm saying? Flannel Artichoke: Okay, wow. Ghost Koala: Very Yeah, typical question. And there are a lot of solutions there already. But the cabinet thing of this question, is that a lot of advocates to cover in Right, right. So we just, that's why I'm trying to see like, candidates, actually, when they are trying to solve this question, like how many advocated or different use cases they actually try before starting implementation, but most of them are just like, hey, you seem like easy, or maybe I appealed, and they just kind of try to rush into the, you know, implementation. That's right. Right. Flannel Artichoke: Right. Yeah. Which is, which is exactly what, which is exactly what I did. Just despite the fact that you specifically mentioned edge cases at the very beginning of this. Ghost Koala: Yeah, that's the best fine. So. So, anyway, um, you did a good job and implementation and communication, but I can't tell you a few things. Because I'm doing interviews a lot as interviewer as well. And I feel like I am supposed to collect data points from the candidate candidates during the interview, right. Okay. But but in other words, candidates are supposed to provide their data pointed to me, which is an interviewer of them, you know what I'm saying? So during the interview, instead of rushing into solutions, they are supposed to help Say appears themselves like they I'm pretty good at squabbling problem solving communication going over educated people who did something like that, that I can feel like a disguise simply the wealth in this data point then in you know, higher emitting data I can't like pleasant for you, you know what I'm saying? Yeah, and this in a mock interview actually, I tried to give a multiple chance for you to to Appeal yourself. But for some of them, I think you didn't unfortunately, for example, going over all the education for the problems. Flannel Artichoke: Right. Right. Yeah. Okay. I agree. I agree. Ghost Koala: Yeah. So, itself is kind of easy, I think you you can be the right answer about time complexity, and space complexity and, and they'll sell you a solution, which is good. And also you call the the book in your implementation during the interview is trying to kill a Pixie, and trying to come up with a filter, which is basically will be for the best ideal situation would be, you, you you get the bulk of your question, by your educated by yourself, it will be then trying to came up with the right solution at the first time. It was not like the optimal, you know what I'm saying? We will, we can work on the ultimate lighting it later. Like gradually. Okay, yeah. Flannel Artichoke: Absolutely, yes, I just really, and that's, that's a really good, no, it's just really take some time up front. Like you're saying fully consider the edge cases, make sure that you're kind of hitting the problem from all different angles, so that I can really understand, you know, the potential pitfalls in the algorithm that I'm writing. Ghost Koala: Yeah, I think that's all like, the interviewers make it plausible that like trying to point out the missing things from your side and try to fix even people inclination for some interviews, or now, they just let you walk into the run to the implementation and expect you to find your problem. In other words, the boss in it depends on so yeah, okay. We need to spell it when working for the same company. Flannel Artichoke: Yeah, okay. Yeah. Right. Yeah. I mean, that's, that's great feedback. And this is a good session to I mean, you know, like I said, I'm just trying to get as much practice as I can hear your feedback is definitely very, very helpful. I really appreciate it. Ghost Koala: No problem. Yeah. So I'm gonna write written feedback for you and you can take a look later. Okay. And I hope Yeah, you will, you should you will do in your future Google. Good luck. Thanks. Flannel Artichoke: I appreciate it. Ghost Koala: Thanks, have a good night.

Want to get some practice yourself?

Become awesome at interviewing, and get actionable feedback from engineers at top companies – it’s 100% anonymous!