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

An Interview with a Meta engineer

Watch someone solve the peaks and valleys problem in an interview with a Meta engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

Interview Summary

Problem type

Peaks and Valleys

Interview question

Determine Peak or Valley from an integer array satisfying the following properties. 1. At any given point in the array, the difference between two elements is +/- 1.Ex. Arr[i] = A [i - 1] is +/- 1. 2. There should be atmost one peak or valley. Return the index of the peak or valley from the given integer array. Examples: Valley - [3, 2, 1, 0, 1] ==> 3 Peak - [4, 5, 6, 7, 8, 9, 8, 7] ==> 5 [4, 5, 6, 7, 8, 9] -> -1

Interview Feedback

Feedback about Orthogonal Warrior (the interviewee)

Advance this person to the next round?
Thumbs upYes
How were their technical skills?
4/4
How was their problem solving ability?
4/4
What about their communication ability?
4/4
TC will be evaluated based on 1. Communication: Edge cases, clarifying questions, communicating your solution 2. Problem Solving: How TC is approaching the question, brute force and optimal, data structures considered 3. Coding: Clean and readable code 4. Verification: Time and space complexities, example run through Went well: 1. Communication: Asked clarifying questions suggesting counter examples. Was able to understand TC's communication throughout 2. Problem Solving: Great job here. was able to come with optimal solution very quickly. Proposed both brute force and optimal on question one. Took a systematic approach to both questions to arrive at the solution 3. Coding: Very good coding skills. Clean and easy to understand code. 4. Verification: Gave the right time and space complexities. Did example run throughs to verify the code Minor Suggestions: 1. Problem SOlving: perhaps writing down the pseudocode might come handy for a more complex question in the hard range or an unfamiliar pattern, to help TC and the interviewer see the gaps if any 2. Verification: Example run through with use if variables like you did in the first question. Other resources: https://github.com/dipjul/Grokking-the-Coding-Interview-Patterns-for-Coding-Questions https://leetcode.com/discuss/general-discussion/460599/blind-75-leetcode-questions

Feedback about Absurd Penguin (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
Fabulous interview, boosted my confidence and feeling great going into the onsite rounds. Thank you so much!

Interview Transcript

Absurd Penguin: So I see you're interviewing for Facebook.
Orthogonal Warrior: I am indeed.
Absurd Penguin: And you're which? Are you going to be attending a screening or is it going to be a full loop? That's coming.
Orthogonal Warrior: This is going to be for the full round. I've already been through the screening.
Absurd Penguin: Awesome. So you already know the format of the interview. So it's going to be about 20 minutes on each coding question. And the last five minutes, they would allow for you to ask any questions that you have for them.
Orthogonal Warrior: Yep.
Absurd Penguin: So let's try to keep it similar. We can do 20ish minutes on each question. I mean, it's okay if you go over, but I'll point that out towards the end. But in the last 10, 15 minutes, I'll give you any feedback that I have for you. Sounds good. Awesome. Then let's jump right in. So here's your question. Let me go ahead and explain you the question. So your input is going to be an array. If you look at this first example, you see that it's steadily decreasing until it reaches zero.
Orthogonal Warrior: Right.
Absurd Penguin: And past this, it starts increasing. Likewise, in the second example, you see that steadily increasing until it reaches nine, and then it starts steadily decreasing. So here, in the first example, this is the valley in the array. In the second example is the peak in the array.
Orthogonal Warrior: Okay.
Absurd Penguin: So you're expected to return the index of the peak or valley, not the value itself, but the index of the peak or valley.
Orthogonal Warrior: Ah, the index of the peak or the valley. Gotcha. Five is the. I was. Sorry. Apologies.
Absurd Penguin: Well, please go ahead.
Orthogonal Warrior: Okay. And it's the index of the peak or the valley. So I, in this case, I could return 3 or 0, because 13 is technically the peak of this array.
Absurd Penguin: No, no. So that's not. So let me go ahead and explain the couple conditions that I have here. You'll get more clarity on what the expected output is.
Orthogonal Warrior: Sure.
Absurd Penguin: So here, the difference between two. First condition, which points out that the difference between any two consecutive elements in the array is going to be plus one or minus one. Okay, so if you look at three, minus two, it's one. Likewise, it is one until it reaches zero. And here it is minus one.
Orthogonal Warrior: Okay.
Absurd Penguin: Likewise, the second example. Let's see minus one, the first two elements, but we look at the last two elements plus one.
Orthogonal Warrior: Right.
Absurd Penguin: Condition for any two consecutive elements. And your output of. Sorry, your input array is only going to have one peak. Or one valley at most.
Orthogonal Warrior: Okay.
Absurd Penguin: It's not going to have two peaks. Not going to have two valleys. It could have zero peaks or zero valleys, but it's either going to be one peak or one valley. It won't have both peak and valley. So in your first example, for something to be considered a valley, it has to go down and has to like, it needs to steadily decrease and then increase. Otherwise there is not really that valley aspect, you know, like within the peak, it has to go up and then decrease. So in the first example, three can't really be considered a peak because there is no aspect of going. The values going up and then down. So there is just this one valley in this example.
Orthogonal Warrior: Okay.
Absurd Penguin: And for the example where there is no peak in a valley, example of that, where there is no peak or a valley in this, because there is no increase and then decrease or there is no decrease and then increase.
Orthogonal Warrior: Right.
Absurd Penguin: In this example, if this were your input, you're expected to return minus one.
Orthogonal Warrior: Okay, cool. And then some. Just some clarifying questions, if that's all right. Kind of implicit in what you just said. There will be at most one peak or a valley. Like, it's not technically possible to have like any, anything with less than three, any array or any array of. With length less than three. It's not possible for this to have a peak or a valley. So. So in that case, you would still want me to return the negative one in say, this case. Does that seem reasonable?
Absurd Penguin: Yeah, that sounds good.
Orthogonal Warrior: Okay, cool. I'm going to go ahead and set this to typescript, if that's all right. Yeah, that's ok. Just so that I can get a little bit of syntax highlighting and. Cool. So the, the, the brute force solution to this would be to start at, start a pointer here at. Oh, sorry, I. It just. Oh, it. Oh, it toggled the whiteboard. Okay, sorry. I, I like clicked something and it disappeared. My apologies. So the, the. The initial, my initial thought is I could do a linear scan of the array starting at index one and ending at the index minus one and then consider the three values. And I'm looking again for the peak or value. Right. So it's for the values on. And given this condition, plus or minus one, for there to be a peak or a valley, these two values would need to be equivalent on either side of the thing. So you've got like 8, 9, 8 here or 01 here. So considering these, these pairs of threes, I can kind of do a linear scan of the array that would be. Doable in linear time with constant space. But I think that we could also do, given that we can do a linear scan, we can probably just do a binary search of the array and there will be at most one peak or valley. Okay. So given this condition, what I can do is I can look at the first two indices of the array and determine whether or not I'm searching for a peak or a valley. So in this case it's descending, so I know that I'm searching for a valley. In this case it's ascending, so I know that I'm searching for a peak.
Absurd Penguin: And.
Orthogonal Warrior: And then just do a binary search accordingly. That would be doable in login time, again with constant space. So I, I think I'm going to go ahead and try and give that second one a shot, if that's all right. So. And would you like me to explain it kind of as I'm going along the code, or would you mind if I just kind of write the code and then I can come back and discuss.
Absurd Penguin: It's up to you, whichever you're comfortable with.
Orthogonal Warrior: Okay, so what I'll do is we'll write a function here. I might do a little mix of both, but if I go quiet, forgive me, I'll try and crank out the code for you. So, find peak or valley. We'll take an array. It is a number array. This returns a number. We're going to set up some left and right pointers. And then, and I'm starting these specifically at. I'm only doing the search in between these indices because this, this index, sorry, my first index and my last index can't be the peak or the valley. So I'm going to just do my linear scan offset by 1. Then we'll say let is peak. Or here, let's. We'll call this target is equal to, equal to. Sorry, we'll put in a couple. So if not, if not array, if not array or array length is less than 3, then we'll return minus 1. So that solves for all of those cases. Then we'll go like this and we'll say array 0 minus array sub 1. So if this is 3, minus 2, if this is greater than 0, then we know we're searching for a peak, else we're searching for a valley. And then the difference between the two elements is positive, negative one. Is there going to be any cases where I have, say, for example, like 4, 5, 5, 6, 7, 8, 9, like this, or will it always be plus or minus one in every case?
Absurd Penguin: Okay.
Orthogonal Warrior: I'm Sorry, I'm asking the question, will there ever be any instances where this is a possibility guaranteed to be plus or minus one?
Absurd Penguin: So if you look at your example, you wrote that the difference between. Sorry. According to the first condition, every two consecutive elements will have a difference of plus or minus one.
Orthogonal Warrior: Okay, so we don't this case.
Absurd Penguin: Yeah. Sorry.
Orthogonal Warrior: Nope, you're just fine. I just wanted to make sure. Sometimes got to account for those plateaus. So cool. So then we'll go ahead here and we'll say while left is less than or equal to right, we'll go and we'll say. And then we'll say const. Mid is equal to math for right divided by two. If. So if the difference between. So really it's just if I. If. Let's see. R sub mid minus 1 is equal to er is. Sorry, if r sub mid minus 1 is less than. Oh goodness. Okay, peak or value. So now we need to go and say if target equals peak. So we're searching for peak. Then we need to go and we need to say else we're looking for a valley. Valley here. And we'll say R sub. And then we need to return the index of the peaker value. Okay, so we'll return minus 1. So if our sub mid minus 1 is equal to our sub mid plus 1, then we're going to return mid. And this is our. And this will always be the case. And then depending on if we are at the peak or the valley, then we say If r sub mid minus 1 is less than R sub mid. So that means that we're on an upslope and we're searching for a P peak. So then we move the left index over to mid one, else we move the right index to mid minus one. And then if in the case of the valley, if the mid. If R submit -1 is less than this, then we need to do the inverse of what we had just done and set right equal to mid minus one else left mid plus one. And then so if we find the case, if we find our peak, we get our terminated, we get our early termination here. Otherwise it will iterate through do the binary scan of the rest of the array searching for the peak or the value respectively moving the indices appropriately. So I think this is about correct. Do you mind if I go ahead and run through a test case?
Absurd Penguin: Yeah. Yes please.
Orthogonal Warrior: Okay, so I. I'm thinking let's start with this valley case here. So we have 3, 2, 1, 01. So it passes this first check. Left is pointing. I'm going to use these. We're going to. We have left is here. Sorry. We'll go like this. We have left here and we have right here. And so we'll go ahead. Is left less than or equal to right? That is correct. So mid is going to be equal to this guy right here. To say are these two equal? That's going to be false. So target is equal to peak.
Absurd Penguin: No, it's.
Orthogonal Warrior: Target in this case is value. You're correct. Sorry, I skipped this line. Target is equal to value in this case because this is descending. So we're going to jump into this is mid minus one less than this. That is true. So it's going to. Sorry, Our mid minus one is greater than. Sorry, my apologies. Mid minus.
Absurd Penguin: So in this case it's supposed to be valley, right?
Orthogonal Warrior: If R0 minus this is. Yes, you are correct. My apologies. You are exactly correct. I have that backwards. Yes. Okay, so three and two. Yes. And four minus five is negative. Yep, you're correct. You're exactly correct. And then I actually think I have these backwards as well. If our mid minus one is less than. No, I have it correct. Never mind. Sorry. Then we're going to go ahead and we're going to move. Left is equal to mid plus one. So that's going to take this. Mid is here. It's going to move the left and right are now both here. And then it's going to go ahead and jump out of this. Jump back to this scan. Mid is math floor. So it gets back to this index here. We're back at three. Is mid minus one greater than or equal to this? That returns true. So it returns three. So that seems to be correct. And then I'll just run the peak kit. I think that's right. Would you like me to run one more validation case?
Absurd Penguin: Can you do this example on line 13?
Orthogonal Warrior: Let's do this example. So we'll go here. It passes first line. So four and five gives me four minus five gives me that. I'm searching for a peak. So we start here. Oh, it did the thing again. So we get our two pointers pointing at these two indices. And then left is right. So we go and we get mid minus one. We get mid is here. And then target is equal to peak which is true. Mid minus one is greater is less than mid, which is true. Left is equal to mid plus one. That puts left here and right is still here. And I'll get rid of these. And then we go. We do the same comparison. We get left is equal to or we get mid is at the same index. We get mid is right here by left. And then we go through, we run our checks again. Are these two the same? No, they're different. So we go ahead and we move left to mid plus one. We get left and right is here. And then we go and we do that same check. It fails again. We get left gets goes here. We haven't returned at this point, so this should return negative one. At that point the while loop terminates and we're negative one.
Absurd Penguin: Perfect. Awesome. So you mentioned that the time complexity is login and what is the space complexity?
Orthogonal Warrior: Yeah, the. The time complexity is login. The space complexity is constant. We only instantiate two pointer variables. So yeah.
Absurd Penguin: Awesome. All right, I'm happy with the solution. Can move on to the next question.
Orthogonal Warrior: Perfect.
Absurd Penguin: Ready? Yeah. So, next question. Kind of straightforward in terms of question. So you're expected to convert a binary search tree to a sorted doubly linked list. And you can assume there is this node that is going to be your input which is going to be the root of the bst. And to give you an example of what is expected, 8, 1, 4. So you can see that this is a binary search tree and so this is your going. This is going to be your input binary search tree. And your expected output is going to look like this. Yeah, you'd expect to return the head of the W and it's going to be an in place conversion.
Orthogonal Warrior: An in place conversion, you said. Okay, so the node is going to have. Yeah, so I'm just noting down the constraints. So the space has to be constant.
Absurd Penguin: Space depends on if you're doing recursion. A recursion could take some stack space. That is okay, I guess that's true.
Orthogonal Warrior: Yeah. Sorry, my apologies. In place. So it's not returning a new set of stuff, but rather it is returning the same nodes but just updating their left and right pointers respectively.
Absurd Penguin: That's right.
Orthogonal Warrior: Okay, and as it's a doubly linked list, would you like. I'm assuming that like one points to three out of the right pointer and three points to one out of the left pointer. Is that seem accurate?
Absurd Penguin: That is right. Yeah. For example, in this input the binary search tree root node is pointing to left child three and right child eight. But on your doubly linked list, once the conversion is done, right six points to left of six points to four and right of six points to seven.
Orthogonal Warrior: Okay. And, and, and you wanted a sorted doubly linked list. So explicitly like for the first and the last Pointer and I guess yeah for the last pointer. So 1 and 8 like you just want their ends to just point to null then I guess yes, that's right. And then the root of the BST in the return value, would you like it to be the lowest value, the greatest value, the existing root, where would you like it to be pointed to?
Absurd Penguin: You can return the head of the W link.
Orthogonal Warrior: Perfect. Okay, so this 1, 3, 4, 6, 7, 8, that's an in order traversal of the binary tree. So my intuition says that we'll just do a depth first search. You're right in mentioning that the. What's it called, the height of the. Or the space complexity isn't going to be constant because we will be using some recursion here. But we'll do an inorder traversal of the tree. It'll be the time complexity will be linear in terms of the number of nodes. We'll visit each node once and base complexity will be the height of the tree and we'll do a depth first search. The tricky bit is these, the four to the six maintaining that link. So I think like if I was. I think what I can do is. Yeah, actually I think what I can do is actually just as I'm doing the inorder traversal, I can keep a pointer to the previous node and then just do my linking to the previous node at each stage. So I'll do. In doing that, as long as I'm doing the inorder traversal, then I do the previous and yeah, that should work. So that should be. Like I said, that should be time complexity that should be O of N where N is the number of nodes. And then the space complexity will be O of H where H is the height of the tree. So if that's all right by you, I think I'll jump in and start coding it.
Absurd Penguin: Yeah, sounds good.
Orthogonal Warrior: Sure. So we'll call this BST to Dall and we'll go ahead here. We'll take a node, take a root and this is going to be. I'm going to. In JavaScript there isn't constructs for this. So I'm going to. Just for the sake of this, I'm going to assume a thing here called tree node that's going to have a val. Yeah, exactly. VAL is a number, A left that is a tree node or null and right is a tree node or null. Just for the sake of this exercise I'll just make. I'll just assume that this is the spec that I'm working off of. So if I'm not given a tree, if I'm not given a root, then I'll just go ahead and I will return null. And then we'll go ahead and we'll do our depth first search. So we'll say. Yeah, we'll go ahead and we will instantiate or we'll create another. I guess we'll just create a function up here that's going to take in a node and the previous. And this is going to go and say if not node return. And then. Is that right? Here, hold on, let me. Actually, I think I might be. I might be overthinking this. So we'll do this here. I'm going to pull this down. Apologies. Pull this down here. We'll do this. If not node return and then we'll go ahead and we'll say if node left. And then we're going to go ahead and run DFS node left. And then, then we're going to go ahead in here. We're going to do if previous, then we're going to go ahead here and we're going to say node left. Is that right? Previous? Yes, that is right. And then previous write is equal to node because it's a doubly linked list. And then we'll go ahead and we'll say previous is equal to node. And then we'll do the right subtree and. Yeah, and then I just pass at the root and return the. Oh, and then I also need to get the head of this. So if not prev here, we do this and we'll also just say if not head then we'll capture head. And so that should be what we need, I believe. Do you mind if I run through a test case?
Absurd Penguin: Yeah, of course, Please go ahead.
Orthogonal Warrior: So, yeah, so we'll jump into the six. This passes six is true. We set null and null. We instantiate this function, we go ahead and we run DFS on six runs. It's defined, it has a left. So we're running in. We jump back into the next version of this. We're at three, we jump in, we go back, same deal. Node is defined, node left exists, we're back at one jump in, node left no longer exists. So we skip, we go over this. Previous is not defined. So we go ahead and we skip this. If not head which is true, head is equal to no or head is equal to the node. So head equal to 1, which is the correct output that we want. And then we say pre equal to node. There is no node right, so we don't jump down there at all. So that seems correct. And so we go and that then jumps up back to three. Three then runs. It is now out of this loop. It jumps in previous got set by one in the. In the. In the recurse version of this. So node left is now pointing to one previous. Right is pointing to three. Head is defined. So we skip that. It runs the right subtree. Previous gets set to node. So 3 is now previous. We run the 4. No node left. No, the previous right is equal to the node. And this left is equal to 3, which is correct. No, right. So we jump out to six. But four I think. Yeah, so I think that works. Four is now the previous. We're now at six previous. Now runs node left is equal to previous, which creates the 6 to 4 linkage. Previous right is equal to 6. That's correct. And then we jump in right subtree. The right subtree then runs into the left subtree. Six is still previous. Seven is now the one running. There is no. It doesn't go down again. Previous is equal to 6. 7. Node left is equal to previous and previous. Right is equal. So that carries the 6 to 7 not head. Node right is none. We jump back up to eight. Seven is equal to previous. Yeah, I think that works.
Absurd Penguin: Awesome. Perfect. And you already gave the time and space complexities. We got done with this a lot quicker than expected. But that's a good thing because I think that's how your interview definitely the interviewer is going to get impressed.
Orthogonal Warrior: Okay.
Absurd Penguin: So let's go with the feedback if you're ready.
Orthogonal Warrior: Okay.
Absurd Penguin: Yeah. So those four axes that they're going to look at and evaluate you based on is communication, problem solving, coding and verification. Communication is going to be any clarifying questions that you asked, covering each cases of everything on the chart. Basically clarifying questions. And also if I'm able to understand what you're communicating throughout your solution.
Orthogonal Warrior: Right.
Absurd Penguin: You did pretty great there. You are clarifying questions. You made sure you got. You're covering multiple examples in terms of you're trying to solve the problem between the first question, second question. I don't see a need to have more examples. So you're good. So it went really well. So I would rate you as highly as possible on the communication axis in problem solving axis. It's going to be how you're solving the problem. It's nothing related to coding. It's about how you're approaching the problem. If you're thinking about optimal solution, the kind of data that you use, stuff like that. Basically about your problem solving skills. So even there you did really great. There's nothing I see that needs to be improved. But I have a suggestion which I'll go over in the end.
Orthogonal Warrior: Sure.
Absurd Penguin: Yeah. So for coding, you were able to pretty swiftly convert your supposed solution to code without any issues. So great job again there. I would rate you as highly as Portal and for four verification. Verification is two things. One is your time and space complexities. The other is your example run through. So you were asking me if I'm okay with doing the example run through. So it's good that you did it and it's kind of, I think even if you don't do it, the interviewer is going to ask you about it. Yeah. So verification, the first example run through was more easier for me to visualize. I mean, I don't have. I would still rate you as highly as possible. It's just a suggestion for you. Okay, so for during an example run through, like you try to use left and right and you try to help the interviewer visualize and also yourself visualize what your, what step you're on. That was really easy for me to follow. I was able to follow second one too, but it was not, you know, like verbal communication of what step you're on. Instead, if you could like maintain a stack phrase or something with a TR and kind of point to what line you're on, okay, that would be good. And I think some interiors might even interrupt you and ask you for it. Yeah, that is one thing. And also the reason why I suggest you doing it is also like, though you did the, like you did use variables and stuff on your first example run through. I kind of had to. Because you have the context on what you want your code to do during the example run through. Just making sure that you're calculating stuff out. Because the valley and peak thing that was kind of interchanged and I pointed out on line 24.
Orthogonal Warrior: Right.
Absurd Penguin: Stuff like that can be more clear and it'd be easy for you to visualize to make sure that you're actually calculating it on your code sometimes because you, you know what you want your code to do. You might easy for you to like, it could happen to anyone where they just don't realize that line is not doing what they do what they want it to do because they know what they wanted to do.
Orthogonal Warrior: Right.
Absurd Penguin: That is one thing I think important to keep in mind because these are just minor things. Nothing really. I think if I were to interview today, I would say that you passed with flying colors.
Orthogonal Warrior: Okay. Cool.
Absurd Penguin: Yeah.
Orthogonal Warrior: That's the feedback I love to hear. Yeah, I can reproduce this on Monday.
Absurd Penguin: Yeah. So fun fact about these two questions is first question is something that I pretty click, I use pretty much when I interview candidates. And second question is something that I was asked as part of my on site for loop. So these are questions that are in the kind of commonly asked. Okay, yeah, that shows that you are, you're ready. And also I said that I have another solution in terms of problem solving.
Orthogonal Warrior: Yeah.
Absurd Penguin: So in these two questions, I feel that you didn't really have an issue. The solution might or might not apply. But there, if you're encountering a pattern that you have completely not really encountered before, if you were to write down kind of pseudo code or something before you start coding, that would help the interviewer see the gaps in your solution. Also yourself see the gaps in the solution. If it's safe, you get a hard question. These two are medium questions.
Orthogonal Warrior: Right.
Absurd Penguin: If you get a hard question, if you kind of work it out before you start coding through an example, because here you have to. You. You have pretty good clarity on what you want it to do, but sometimes you're trying to solve the question and write the code at the same time. That could kind of take longer, I feel.
Orthogonal Warrior: Right. Yeah, it's helpful when you kind of have an idea, but when you're, when you, when you're stuck kind of working through it a little bit more. Having the pseudo code will help you kind of identify gaps in any algorithm or any algorithmic complexity before you're actually in the thick of the code.
Absurd Penguin: Yeah. Because once you start coding and if you're trying to solve and code, you might probably end up taking all the time that you have for the question.
Orthogonal Warrior: Right.
Absurd Penguin: So if you write down the pseudocode, the interviewer can also. I'm not saying the interviewer will give you a hint, but they could if they see if you're almost close to the solution and there's just this one nudge that you need. So that is just a suggestion. It's not really an improvement either. It's just a suggestion that might come handy.
Orthogonal Warrior: Okay, so I guess to the, the you had mentioned, like, with the first one, there was like, there's kind of some natural, like, visualizations in terms of like the left and the right pointers. So for this, like, if you jump down to like line 57. Right. So for this, be helpful if I was like, okay, so I go and I do something like this where I like, okay, I push, you know, six onto the stack and then we're on the. We're on to one and then we go and we process one. One gets pushed onto our list, then one gets popped off the stack. There's no right tree. So now we're at three. Three gets processed, then we push or something like that.
Absurd Penguin: Maybe even use like what your previous is going to be at this point.
Orthogonal Warrior: Okay.
Absurd Penguin: The ones that matter. You don't have to like write down every variable that is in there but previous and see the node are like the important things like that being used to update.
Orthogonal Warrior: Right, right, right. Kind of like. Kind of like a debugger. Give them like some variables so that you. I can kind of help them track the. The changing of the variables. The. The key variables through the actual process.
Absurd Penguin: Yeah, right, exactly. And so is it also I was easily able to follow I think because this is like the optimal solution. That is if you search for the solution for this question, you'd find similar solutions. And I have seen candidates approaching it with a different solution which is also optimal. But it is not solution that is say on leetcode or somewhere. In that case, if it's a solution that's not the interviewer had looked at before, but it's still a working solution. Yeah, especially in those cases. This example run through with the variables and stuff is even more helpful. If they don't follow, they're going to waste your time.
Orthogonal Warrior: Right.
Absurd Penguin: They're going to ask you oh, can you repeat that or yeah, they would ask similar questions probably.
Orthogonal Warrior: Okay, so just make, make sure that I'm being. If I. If it's not a kind of a. I mean this is kind of a boilerplatey solution in. In that it's like it's a standard in order traversal and so like there's kind of a lot of boilerplate. So if it's less or I'm doing something like my algorithm a little bit off the rails, make sure that I'm tracking those variables and helping the interviewer follow along.
Absurd Penguin: Yeah. So for example, some candidates even do a solution where they try to link the rightmost node of a subtree to the. At the left of the root and left most node of the right subtree at the right of the root as it's not subtree as in right left most node in the right subtree. It's an approach. Some people say, I mean there are different ways to approach it.
Orthogonal Warrior: Right. I mean you can push all these values into an array and then iterate the array or something like that.
Absurd Penguin: Like there's ways so yeah, like, especially when you're not going the conventional way that the interior is familiar with. In those cases, the example run through with proper variables and stuff. Especially helpful.
Orthogonal Warrior: Okay, cool.
Absurd Penguin: Any questions?
Orthogonal Warrior: Yeah, actually since we have a few minutes. So I also, I'm going for an E6 position. So like coding is kind of the thing that I'm over indexing on because I do a lot of systems design. But like, would you have any feedback or any tips on like what I should expect for like an Ease or an E6 like design interview? Like what, what are some that I should look for for that System design interview?
Absurd Penguin: Yeah, system design. I know I haven't really done system design interviews for candidates, so I can't really help so much there. But I definitely can say that for any position they are going to like, coding is important, but they're also going to put a lot more weightage on system design than coding.
Orthogonal Warrior: Right.
Absurd Penguin: For example, my manager, he said that though it was a management position, he still had a coding round and he didn't do so great, but he did really well on the system design and he had multiple. Like for say for an E4 or E5, they would probably have like one or two system design rounds. How many do you have?
Orthogonal Warrior: I have system design and they're behavioral.
Absurd Penguin: How many system design rounds do you have?
Orthogonal Warrior: Two.
Absurd Penguin: Okay, two. Got it. So E5 I think might have one, I think. But anyways, like the weightage on system design is a lot more for an E6 position than for an E5 position. They kind of tend to get deep in terms of what questions they ask. And also it's also about how you lead as to what point you want to focus on. You might take the lead and get deep into the say for databases you might start going in deep and they start asking more questions in terms of that. If you're staying somewhat vague, they would take the lead on what is the particular component they want you to dive into. Sorry.
Orthogonal Warrior: No, you're just fine.
Absurd Penguin: Sorry that I can't really help so much because I don't really have a lot of experience.
Orthogonal Warrior: And then I guess the behavioral interview is the other one. Are you like, is there what. What kind of should I expect in terms of the behavioral interview?
Absurd Penguin: Behavior interview? I'd say like write down your stories really well. Make sure that you're like when you write down your what. Whatever stories, try to look at about 10 behavioral questions or so they're going to ask you about situation of conflict or have you had some issues with like when there was A conflict in the team and how you still made sure that your project went through, or they would probably ask you about a failure and how you kind of made sure that this failure. There was lessons learned from the failure.
Orthogonal Warrior: And right now, make sure I have down. Make sure I have my stories kind of evaluated and prepared and just kind of well thought through beforehand. And then, and then the whole. The star format. Right. They like the situation, task actions and result. Like frame everything kind of according to that format, right?
Absurd Penguin: Yes, that's right. So make sure like you get deep in terms of when you. They're going to ask specific questions. So make sure that your story is not vague. Yeah.
Orthogonal Warrior: Okay.
Absurd Penguin: As long as you have the technical details of it very clearly written clear in your head, they're definitely going to get to it.
Orthogonal Warrior: Okay, cool. Well, I. Yeah, this is the. This, this. I think I. I mean, I guess, like, if this was the interview like you said that I did. Well, like, would there be any feedback? Like anything that, like, anything else that I should expect or like, is it. This is good to go.
Absurd Penguin: Yeah, this is good to go. Just keep getting exposed to more patterns. I see you're already pretty well prepared, but the more patterns you look at, the more luckier you get that too. Right?
Orthogonal Warrior: There is a certain amount of luck for sure. If you get. If you. Somebody goes and gives you a backtracking problem and you haven't practiced your backtracking, that becomes a pain. So.
Absurd Penguin: Yeah, exactly.
Orthogonal Warrior: Okay, well, I will just keep on keeping on and. Yeah, thank you so much for your time.
Absurd Penguin: Yeah. I'll send you all whatever we discuss as part of return feedback, terms of what actions, what they look for, and also minor improvements that I suggested. I'll write that down.
Orthogonal Warrior: Okay. Yeah, no, that would be fabulous. Thank you so, so much for your help.
Absurd Penguin: Thank you. Have a great day. All the best.
Orthogonal Warrior: Take care. Bye.

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.