Watch a technical mock interview with a Google engineer
Paisley Wallaby, a Google engineer, interviewed Cashmere Panda in Java
Share
Summary

Problem type 

Regex matching

Question(s) asked 

Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial).

Feedback

Feedback about Cashmere Panda (the interviewee)

Advance this person to the next round?
  No
How were their technical skills?
3/4
How was their problem solving ability?
2/4
What about their communication ability?
3/4
One thing you did that was great was taking the time to step through examples by hand before running your code. As you noticed, this is a good way to find bugs in your proposed algorithm before you even start coding. We talked quite a bit about what you could do better, but to summarize, I think doing well in interviews like this is 50% problem-solving skills and 50% having a mental "library" of problems you've seen before, and being able to pattern-match so you can apply what you know about a similar problem to one where a few of the details are new to you. The latter is easier to build with practice than the former -- the more practice problems you do, the more likely you are to already have seen a similar problem to the one you're being asked to solve in an interview. That nebulous "problem-solving skills" piece has something to do with being willing to take a step back and rethink your strategy, as we talked about; also knowing how to recognize when a problem can be solved with recursion. Practice does help with this too: the more recursive algorithms you study, the more you'll notice when a problem can be broken up into smaller subproblems. If you want to keep working on this problem on your own, you can compare your work against the solution here: https://leetcode.com/problems/regular-expression-matching/description/. I thought your communication was good and you did a good job of explaining what you were thinking. This is a challenging question, and I know you said you were new to practice interviews, so don't be discouraged and keep practicing!

Feedback about Paisley Wallaby (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
Paisley Wallaby: Hi can you hear me okay? Cashmere Panda: Yes I can. Paisley Wallaby: Great, how are you? Cashmere Panda: I'm good, how about yourself? Paisley Wallaby: Good. What language would you like to use? Cashmere Panda: I would like to use Java so I will toggle this to Java. Paisley Wallaby: Great cool. Are you familiar with regular expressions? Cashmere Panda: I'm familiar with what they are and yeah. I do know what they are. Paisley Wallaby: Okay well this question is about matching a simple subset of regular expression so nothing too complicated. So, write a method that takes two strings as arguments. S a string to match against and P a pattern and returns a boolean denoting whether S matches P. P can be any number of the following: a lowercase letter which stands for itself, the dot character which stands for any character - the wild-card, or the star which must follow another single character and stands for zero or more occurrences of that character. So star can never be the first character in a pattern and it only applies to the one character character before it. And you can assume that the pattern is well-formed so that it only includes these things and that the star is used properly and that it's not the empty string. So here are some examples and I'll go over them. In the first example the pattern is ab, so that would only match the string ab, so this would be false. In the second example the pattern is a*, and the string only contains a so that does match. In this example the pattern, .* matches any strings, so this returns true. In this example the pattern is ., which matches exactly one character that can be any character, so since S has two characters, this returns false. Here the pattern is any number of c's followed by any number of a's followed by a single b and S has zero c's some number of a's and a b so that's true. And finally the pattern here is a*., so any number of a's followed by any one character and S has aa, which matches a* and then a which matches ., so that's true. A couple tips, so don't worry about the performance of your code at first just, you know, try to get something that works and even if it's naive we'll we're kind of proving it after you have something that runs and is correct. Try to think out loud as much as possible rather than just writing code, say what you're thinking and it's easy to start out doing that and then kind of slip back into thinking about the problem, so just try to watch yourself for that. People usually do better if they try to write out their algorithm as pseudocode or in english in the comment before they try to to write code, so that separates the problem solving part from the part about trying to translate that into code. And finally, try to if you want to think of more test cases to use and it also helps when you have the pseudocode written to sort of step through some examples just mentally and see if your algorithm works. Cashmere Panda: Perfect thank you for that, some great tips um yeah. So I'll try my best to think out loud as I start coding so let's it's go and declare a function header regex, which takes in the easy part, two parameters. Um so right off the bat I'm thinking of iterating through each character of P and then basically within that I'll have a bunch of if statements to check characters in P for either 1, 2 or 3 so and then... I'm trying to think if the structure should be a double nested for loop. Um actually maybe I should be, I should be iterating through each character in S and and then... yeah I'm trying to think if I should iterate through S or through P. Um I guess it doesn't matter as long as I am careful about stepping out of bounds because the length of S and P are not necessarily the same. So basically like if we go through a simple, the first case aba, S is greater length than P so then i would look at the character a and then so there's a match initially, so we go through the second character B and that matches and then I go to the third character and P since we're at index location 2, 2 is greater than the length of P - 1 I guess. We know there's no match. Basically a is matching to an empty string, empty character. So essentially that's a false. In the case second example aaa*, it's luckily the same length, so there should be no issue there. I guess I can talk through, so their index 0, a and a match so that's good, and then index 1, so here will be the first if statement right? If P[i] equals a *, then it's automatically true. So let me think about this. So a * is 0 or more occurrences of that character so um I'm trying to think there's a clever way... So if it's an ab... If it wasn't ab, that would also be true. If it's just a, then wait... Sorry I'm just going... So which much follow another single character and stands for occurrences of that character Ok so the * is always on the right side of the a? Paisley Wallaby: Yeah. Cashmere Panda: Okay so I guess does that... Oh shoot so that means that every time I'm looking at P, I want to check the following character... Um so I need to be careful about checking the following character and making sure that following character is not the end of the index, end of the string. Paisley Wallaby: Right right. Cashmere Panda: Yeah so every single time there I have to check i and i+1 of P. So if I do that and the following character is a *, then then basically... I guess there will be some sort of loop. Um I have to advance the position of S 0 or you know, X number of times. Yeah maybe I should just start writing, otherwise I'm just talking and rambling. So let's just do the first case... Oh yeah I guess the Regex should be returning a boolean and my my ultimate plan is to return true if it goes through the for loop without returning false in the inner body of the loop. So if a equals b, just continue it. Um yeah let's deal with the * case. Um oops there's a mistake here, should be P. I think I was trying to just use one index but I feel like we definitely need two indexes. Um so let me just consider advancing i... Oh wait so I need to check for... So basically keep checking for the letter b until we see another character. I mean this doesn't account for the fact that the first character is um knotted, so while a is not equal to b. while a equals b, keep advancing i. So then if a is nothing, as in in the case let's say we had S equals aba, P equals um should I say *c*, this is true correct? Paisley Wallaby: No so that wouldn't be true. I'm getting a little echo from you. Cashmere Panda: Oh sorry is this better? Paisley Wallaby: Yeah that's better. So um yeah so in this case P would only match strings that are only made up of c's. Cashmere Panda: Oh so um I guess I was boggled... My mind was stuck on the fact that 0 or more occurrences of that character. Paisley Wallaby: So there it would match the empty string, so like 0 c's or the empty string or one c or two c's etc, so it would only match things that are only made up of c's. Does that make sense? Cashmere Panda: Ok so empty string is ok. So this would be true if S was empty right? Paisley Wallaby: Uh yeah that would be true Cashmere Panda: That would be true but then uh... okay so let me just you know back up a little bit. Would this be true, it would right? Paisley Wallaby: Uh yeah that would be true since it's zero c's followed by one B. Cashmere Panda: Okay okay, I was just trying to be careful with the case where there's zero c's. Um so yeah let me just... I should just go through it. So in the first case, yeah my variable naming should probably be better. I'll just do S[i] and then P[i] is probably better. So in my example S[i] is b and then P[i] is c and so j + 1 is looking at *, so I mean my next P is basically star and then I go into the while loop. Is b equal c, it's not. So I just automatically break out the for loop which is what I'm looking for. But if let's say I have bbbbb like that, then a would be equal to... S[i] would be equal P[i] and then I would just keep iterating. Oh no, but then if this way... I messed up the input... So then i would incremental until position zero, one, two, three so it would it will be on the c at this point. Yeah I think this is good. I probably don't want the i++ in the for loop anymore. Okay so let me continue. Okay so what's the dot syntax. So the dot is more straightforward I believe. It's just simply looking at the current element... Is P[i] equals the., then it matches any character right? It says which stands for any character. So I believe it's just continued right? I feel like it's a little too straight forward, but let me just go with that for now. Um so if it's any character, we just continue. Well I got rid of the i++, so I'm just going to probably have to add a... We advance both. So let's just go through an example, lines 69. The first character a. So ~S[i] is a and then P[i] is a ., so they're not the same, so I go to the line 31. J+1 is what... I do go into the next P, which is a *. Oh okay so um... So it is an i and I do go into it and so my S[i] is a and P[i] is a ., so great so here I just do or S[i]. Dot just means that I can match any character. So I do want to advance. No I don't want to keep advancing though... wait no I do want to keep advancing... Basically this could... Oh I shouldn't changed the original, let me just add a new test case... This was like xyz, you know abc. P equals .*. Then what what is this thing saying? This is saying that any characters zero or more of ., which is zero or more of any character right? So then here even though on line 36, S[i] is never going to match P... Yeah I think this is right. So I'll just keep advancing i until the until the very end. But wait, now I'm thinking... I might advance too far.... Wait but if it's dot star, it's always true right? Unless there's more stuff going on so... What if I have like .*bc. It goes all the way to the end of S. I'll have more characters in P to process. Oh what if this was yy? So I probably want to... I probably don't want the for condition to be the end of the string of S, should be j, along the lines of while j is less than `P.length() to avoid the situation where I just iterate through the entirety of S and I just break out the for loop, even though I haven't seen yy in P yet. So I'll come back to that part just to double check. But I think this is good for dot. Um okay so now I have to deal with the case where there's only one . if P[i]... did I make a mistake on line 40? No, I didn't okay. It just escaped my head um... So yeah I did take care line 40 to 43 for the base case where there's only one character. So I want to increment j here. Is that at? Uh okay let me go through each example then. Paisley Wallaby: Okay. Cashmere Panda: So I'm just going to copy the examples so I don't have to keep scrolling. Let's go through your examples because your examples are probably... so let's do this simple aba, so I'm at a equals a, so I continue. Oh yeah, oh great. Good, I do want to increment both i and j here. But wait no I don't want to. I do want to do the check first. Yeah so I think the placement for characters is too early because I always want to check for the star right? So else just do a straightforward... Um I mean I notice I could probably... There's a bit of redundant this is... Let me organize real quick, so else if... S[i] == P[i] or if P[i] == any character, increment both of them and continue. Oh okay so I guess the subtle thing is if it's a star, I don't want to do j++ because I would just hit the star so I want to do j+=2 I believe. Okay um I keep getting... but so I noticed that all of my logic is within that if j+1 < P == length check, so probably on if once we're on the last character of P, it does nothing, which is not correct. But let me just go through the line 53 example one more time. So next P in this case is b, which is not, so I go through the else if case in line 38, and S[a] == a, so then I increment both j and i and I continue. In fact the continue is redundant now. I go back, so b == b, similar thing and now. So now j is greater than so I break out the for loop, but I still haven't processed a yet. Is there an elegant way I can do this? I'm considering a case where now i is in position 2, j is at 2, so we're out of the for loop. Um but I still want. Ok so I believe it's a matter of checking if i... We're not at the end of this string. If i is less than... so ok so where am I? i is at position 2. Let me double check. So ab finishes then j is 2, which is greater... 2 is less than 2, so it breaks out of the for loop. And then i is not less than 3. Well 2 is less than 3, so it should return false, but let's say my P was aba. Um then i would be 3. So we're good. Then we return true. Ok I think that's okay. Paisley Wallaby: Can you... I don't quite get what that line 47 is doing? So you're saying if i, which is counting position in S, if your index within S is less than the length of S, you return false? Cashmere Panda: Yeah so basically I'm trying to account for the fact that there are still remaining characters of S that have not yet to be seen because we already broke out of... Paisley Wallaby: Oh I see, I misread this, you're outside of the loop. So yeah but this makes sense. I thought this was inside the loop. Okay. Cashmere Panda: I imagine it's really hard to follow me because I'm kind of talking as I'm coding, but that the gist of what I'm trying to do is there's remaining characters of S, that we haven't seen, but we already went to the end of P right? And then so automatically that should be false because because we're saying that the P is um... We're saying that we reach the end of P, but we haven't... I want to be careful with what I say, but basically there that's my rationale um... Paisley Wallaby: Yeah you've reached the end of the pattern, but haven't but then do all the characters in the string. Cashmere Panda: So yeah effectively that's like equivalent of saying x equals whatever and then P equals the empty string right? I mean it's equivalent to and then this is false. So yeah um I think that's good, so let's finally go through the second example so actually it will be P equals a*. So straightforward the first a we go through should be no problem and then the second character, well this is the part we have to... Basically I won't go into four... In the second iteration of the for loop because of my check I won't go inside so that's... So I should just treat it... I wish there's a... maybe I should write a helper function because I don't want to duplicate all the code from line 34 to... Paisley Wallaby: Yeah sure. I think that's a good idea. Cashmere Panda: Actually line 40 basically. Although come to think of it, it's not that much code, so I'm going back on my word again. Basically because my third line 31 check is anticipating the possibility that there's a star right, but line 45 to line 48 is when we know... I should just write comments... Ok one more time line 64 example, I use 1, so j+1 is 2, which is not less than 2, so then we go to else-if, so is a equal to star? No. Okay what am I... I apologize. So now we do... Yeah let me back up, I assume the second character was not a star. i equals 0, j equals 0, a equals aI skipped a set one more time. So we do go to line 31 and j plus 1 equals 1, which is less than 2. So we go into line 32 next P, get next P, which is a star, so we go to line 35 or line 36. While a equals a, while S[i] equals P[i], which is the case, increment i, so i is at 1 now. And then I do... So a is... So a equals a, I increment I... oh yeah and a is still equal to a, so I increment i again. So i is now a 2 and then j plus equals 2, which is... so now i is 2 and j is also 2... So then we break out of the for loop and i which is two, is not less than 2, so that line 52 evaluates to false, so then we go to the line 54 and return true. Okay I think that works. So go to the next example, which is just simply .*. Paisley Wallaby: I don't want you to run out of time so maybe skip to the last example line 72, I think yes we're gonna do. Cashmere Panda: Yeah okay so the last example is aaa, a*. So first iteration a equals a, no problem there. Um oh wait, what am I saying. So next P equals star, yes and then I integrate i all the way to i equals 0, so basically the while loop runs until... Oh and there's a gaping problem which is that I'm not updating S[i], my bad. So I want to be careful of index out of bounds so that's while S[i] is less than s.length(). what if it's greater, what if we are past it. Then we want to... We might run into an index out of bounds here. I'm trying to think of a situation where I reach the end of S, but there's still more P more patterns. So like let me just duplicate the last example aa, but then P *., so that should return. Dot is any character, okay so yeah, so that's fine. So I reach towards the end of S, but what if P still had more characters like a b, then this should be false because we're saying that we want any zero or more a's followed by one b. So then P also needs to be checked for lengths in a similar fashion as line 56 I believe is the rational. So not only does i have to be less than S.length(), j also has to be smaller than P.length(). So in the line... let me go through the base example, line 101, because I keep jumping back and forth realizing mistakes. Basically I iterate through the end of S and my while loop, the first condition y less than S.length() evaluates to false, so then we break out of our for loop, I go to line 40. i is equal to S.length(), so we break and but then P is still stuck at... well not P. I think I want to do the a plus equals two before the break... um is that true? So can you explain why line 101 is true? Paisley Wallaby: Sure so... So we look at the first character a and that matches a* so we go on but we're still sort of in the matching a* state and then we look at the next character a so that's fine, also a* and then the last character a matches dot, so that's also a match and now we've used up all of S and all P. Now you might notice if you're paying attention carefully, I sort of omitted the detail of well how do I decide when I stop matching a* um because if I was not being careful, I could say well I'm just gonna as long as there's an a, I'm going to keep marching through S and then I'd be at the end of S, but I would still have this one dot left. You can uh, you can account for that. Cashmere Panda: I can. Yeah so right off top of my head, I'm thinking of just simply checking if that last character is a dot... Um if it is then we're good, because we're saying that... Yeah, have to be careful here. Because in this example... So given my current code, I would blast through all of the a's and then, so my index tracking S will blast through end and then P will also blast through the... Well not blast through but P will be pointing at the dot and then because my current check is just j less than P.length(), that would actually evaluate to true. So then I'll return false. So I was thinking on line 56, if I can simply just add.... Um so basically I'm saying... Or actually that's a little... I think I need to do or... Um no wait... Yeah I don't think I can do that because I'm thinking... Assuming that the last character is a dot, but then there could be more characters right there be like abcx whatever. Paisley Wallaby: Yeah exactly. Cashmere Panda: But that's not um... So now I'm trying to think if I need to look ahead similarly to how I'm looking ahead by one to check for the star, do I need to... I might need to look ahead two steps to see if there's a dot in front of the star... Um if that's the case... Because basically I'm trying to come up with something fancy. P equals x and *., it's equivalent to just star I believe. Um let me think about... which must follows there is so that means zero. Actually it's not equivalent because we come *. is saying one, at least one occurrence. Paisley Wallaby: Well *. wouldn't be a legal pattern do you mean .*? Cashmere Panda: Oh yeah, .* would be any zero or more of any characters... but... *. is not is not um... Is not allowed? Paisley Wallaby: Well not by itself so, star refers to the one character before it. So here there's no character before it so it's not well formed according to these rules. I mean you do have a *. here but the star applies to the a rather than the dot. Cashmere Panda: Right and then the dot applies to the a as well right? Paisley Wallaby: In this case yeah. Cashmere Panda: Okay yeah I'm trying to jog my memory so... Let's say S equals empty string, P equals star. I think the subtle... I'm trying to use an example to illustrate, but um basically I believe a*. means I want one or more characters of a, so... Paisley Wallaby: Well not necessarily. So another string that would match is... Cashmere Panda: Oh yeah, yeah because the dot would match the b right? Paisley Wallaby: Yeah so it's saying I want a string that's... well I'm trying to think of a better way of saying this. I want a string that's 0 or more a's followed by one single character that can be any character. Cashmere Panda: So okay how do I blast... If I blast through the a's, then I still need to look for... So maybe I just need... I'm thinking um in the example of 102 now, after I break out of the for-loop, I need another loop to traverse the remaining elements of P. So basically for you know for j less than its length. Basically I iterate through the last dot so I should have just wrote it... So basically just iterate through the rest of j and at this point my i is already out of bounds. Let's say I encounter a dot, what do I do? Is there any... if it's a dot, its automatically... I'm just thinking out loud right now. Basically if dot the only input that is not valid is empty string right? Well couldn't I just simply say... But what if I have another dot, then that means I'm expecting... huh now I'm starting to think the whole thing where I'm just just blasting through... Basically I'm going through all of the a's but I need to have to check ahead of the star how many dots there are. So let's say there's three dots ahead of the star, then I only traverse you know... So I go through... Um let me just use pseudo code so you kind of follow my thought process. My thought process is check how many following the star right? Let's say it's k dots, then I have to iterate... So let's say a happens x times. Basically I wanted traverse... you do i++, x - k times. But the problem is precisely that I don't know how many x's there are. So maybe I have to just go in the entire a and then just backtrack the index of i so something along the lines of you know... So I have one more idea and I guess if that's totally off-base I would probably need a hint, but my idea is basically in my main for loop, I add another if statement if the current character is a dot, then I have to somehow subtract my progress. Oh okay my previous character is a star, then I want... So basically if my previous char is star and current is dot, move i backwards until... Ya move i backwards so then we get another chance to process the same character of S, is that really off-base if that's the case I guess I could? Paisley Wallaby: Well what about um... I want to give you another example but um... Okay so yeah... Cashmere Panda: Because if there's two dots, right? If there's two dot, your previous character is also a dot. Paisley Wallaby: Well I'm on line 121, so I am writing two examples here so this should... This first one should be true. This one should be false. So here what I'm saying that it's not just if the next character is a dot. So here, the way you're thinking about it at least, you'd want to do some kind of backtracking. But in this case you wouldn't, because you're not seeing a b in the string, so like here backtracking won't result in a match because the character required at the end is not the same as the one that's in the star. Cashmere Panda: Right right um... Paisley Wallaby: We're pretty much out of time, but I'll just tell you that the way to handle this issue that we've identified is using recursion, so basically you can say like, okay I'm going to make a recursive call matching so... Let me back up a little... So basically what's going on in let me go back to line 115. So basically each time you look at a new character in S, you can make a choice so you're at index 0 here and you can either regard a* matching 0 characters and go ahead and try to match a against . or you can consider a as matching a* and you can say okay a matches with a*, now I'm going to try to match aa against the same piece. So to write it out you can... Right so the two choices here you could say that a* matches the empty string and go add and try matching aa against the character dot which would fail or you can say well a matches a* and I'm going to try to match the rest of the string aa against a*. and then eventually you get to a and you realize that the first choice actually works. So basically it's like each of these two options is a recursive call to your matching function and you sort of try advancing into the pattern in a different way. So that kind of takes care of this ambiguity. Do you have any questions for me? Cashmere Panda: Oh um yeah like I see where this is going. Basically if you solve it recursively, so each function call would have to would branch two times? Paisley Wallaby: Yeah exactly. Cashmere Panda: And one branch we pass an empty string? And then the second branch we we just pass in one character, and then the the empty string in this case would what evaluate to true. So as long as one of the branches evals to true, then okay. I'm just reiterating what you just told. Sorry no, I know I went over time, but just very quickly like um, yeah like did you have any feedback for me? I'm very new to this interview.io platform, um and yeah any kind of like feedback, harsh feedback.Just lay it on me you know because that will be more helpful for me. Paisley Wallaby: Yeah I'll give you written feedback I'll try to put most stuff there, so you'll have it for reference. What was I going to say? Yeah so I gave you the tip-off about recursion at the end in case you want to try and solve it on your own time, you know now that you know that. It's a fun problem. But I think you did a good job of communicating and sort of talking through your thought process, I think it is good to step through examples like you did. But I guess like I feel like you know something about it could have maybe been a little faster, just like I think if you had maybe gotten to realizing that this kind of backtracking was necessarily, like with this example if you'd realize that maybe 15 minutes earlier, maybe would have been able to write some code that would handle that. So um so yeah I don't know it's yeah, it's difficult for me to say what you should have done differently, but I guess you know, I've told this to other people, like once you notice your code kind of growing a lot of special cases, that's a good time to step you know step back and say like well you know what's going on here can I do this more simply? Cashmere Panda: I see that's kind of the hint. I wasn't sure if you still had like one minute or two for a follow-up question? So I'm kind of like practicing interviews in early stage and I guess it's really hard for me to... Like some questions I either just know it or I just don't, I'm just drawing a blank. I know practice makes perfect but at a certain level I feel like it's just you know I can't imagine myself ever thinking about that solution after reading the solution, so I don't know is that just like just... For you personally it's just like practice practice practice going through the grind until your brain just muscle memory? Like for example I'm really slow at go, as you probably know, very very slow at going through code, just like the indexes always trip me up, but it I guess if you do it enough times then you get faster? Paisley Wallaby: Um yeah like practice is important but also like... I mean with this problem there's sort of an aha moment, which you know as most people that I've given this question to don't have that on their own, you know? Like I either give a hint because it's earlier on in the interview and then they kind of get most of the rest of it or they just don't get there and I don't... You know out of the people that do have the aha moment and solve it I don't know how many of them have seen it before, so you know it's hard for me to say how much of success on this particular problem is due to having seen it before and how much of it is you know measuring someone's problem-solving skills, which is you know ideally it would be a question that anybody with good problem-solving skills can get. But I'm you know I'm not really sure how to tell. But from your point of view, like I'd say you know practice a lot but also like I mean, I have a couple questions that are all basically tests of like do you think of recursion like and I think with a lot of people's experience and education they may not think of recursion right away, so maybe as a more general tip like if you're, if you are getting confused, if you're writing something with nested loops and you're getting confused about indices and like having a hard time following your own code like, consider that to be a sign that maybe you could use recursion like because this problem actually gets a lot simpler once you do that, so particularly practicing with recursion and sort of learning to recognize like when a problem is calling out for recursion, I think that can help because then you avoid like writing a bunch of code that gets really hairy really fast. Cashmere Panda: Sounds good, thanks for the feedback. Paisley Wallaby: Yeah you're welcome. Cashmere Panda: Yeah um, yeah I guess like what I noticed is once I you know set my mind into a particular way to do it, like very early on I thought oh this is definitely a iterative thing, um. But then I'm already too far in to the iterative approach, it's hard for me to bounce back and think like oh, recursion is the way to go I should really start from scratch. Paisley Wallaby: Yeah yeah and that's that's one of the things yes go ahead? Cashmere Panda: Sorry no I was just saying I think that's just lack of experience, probably more experienced people would be more more than comfortable to start from scratch, versus for me it's like oh there must be some tricky way to handle the indices and plus you know I'm really really far into it, so it's a little risky for me to start from scratch. you know what I mean right? Paisley Wallaby: Yeah I think part of that does come from experience. Cashmere Panda: Right I do need to get fast that's for sure. Paisley Wallaby: Yeah but like um you know like and this is not an accident, like I think this is one of the things that interviews can legitimately measure that you're able to like be flexible and not get stuck in one approach and sort of watch yourself and say like okay well this is getting complicated so maybe I should be doing something else. Um and it is you know very tempting to just kind of stick with what you're doing because it's kind of scary to just like throw away what progress you've made, but um but it can be necessary and part of this is something I'm still figuring out how to do as an interviewer like, okay when do I suggest to somebody like hey maybe you should take a step back and turn it around. But I would also say like, you know whenever you find yourself like trying to do something clever or looking for a trick like, you know step back. Because like I think you know good interviewers don't give like questions where a whole lot of cleverness is required if like... There's a difference between like clever code and like understanding a difficult problem and I in my questions I try to come up with problems that require thinking but that if you sort of think systematically, you'll get it and the code will not be cryptic. And I try not to ask questions where you need to do something really you know convoluted because you know if you're writing code in a real situation, like clever code is hard to maintain. Cashmere Panda: Yeah especially in an interview setting. Paisley Wallaby: Yeah so if you find yourself trying to be clever basically like ask yourself like okay maybe rather than like trying to make something more clever maybe there's another approach to this that is that is a more straightforward solution in the end. Cashmere Panda: Cool yeah you know obviously I want to take too much of your time, so thank you very much. Paisley Wallaby: Yeah enjoy the rest of your evening or day. Cashmere Panda: Yeah you too, so.. Paisley Wallaby: Bye. Cashmere Panda: Yeah um oh the awkward moment where you say you don't know when to say bye. Bye.
Want to get some practice yourself?
Become awesome at interviewing, and get actionable feedback from engineers at top companies – it’s anonymous and free!
©2019 Interviewing.io Inc. Made with <3 in San Francisco.