Swift Interview with a Meta/Facebook engineer

Watch someone solve the odd even linked list problem in an interview with a Meta/Facebook engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

Interview Summary

Problem type

Odd Even Linked List

Interview question

1. Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. 2. Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed).

Read more about the questions

Interview Feedback

Feedback about Serpentine Hawk (the interviewee)

Advance this person to the next round?
Thumbs upYes
How were their technical skills?
3/4
How was their problem solving ability?
4/4
What about their communication ability?
4/4
Hi Serpentine Hawk, hoping interview was insightful for you. You did well and would definitely get a hire signal if this was a screening interview, and could even get a hire signal for onsite (albeit not with high confidence). You came close to solving two questions. Just that your coding was a little slow, and you completely missed out on doing dry run for your code. That's pretty important. Here's my detailed feedback. Feedback ===================== - All the ✅ are your strengths. Keep them the same way! - All 🟡 are things you are good at, but an improvement would certainly help you a bit too! - All ❌ is where I want you to improve from next time onward. Communication ============== - Clear in communication ✅ - uses comment space efficiently to explain solution ✅ - Good to mention you're a lil weak in Linked lists. Will help interviewer probably test you on a different question for 2nd problem. ✅ - “I think we’re okay” when interviewer is probing towards optimising ❌ - Talks while coding and keeps interviewer engaged ✅ Technical Knowledge ============== - Knows about LL ✅ - Knows about time & space complexity ✅ - Knows about BFS ✅ - Couldn’t answer questions on space complexity for q2 ❌ - binary tree could be completely skewed to one side, so space complexity would be O(N) then. - even when tree is fully balanced, the last level would have O(N/2) elements in queue/array (for BFS), so space complexity would still be O(N). Problem solving skills ============== - Found brute force and optimal solution yourself in a few minutes ✅ - Got optimal solution for second question immediately ✅ Coding skills ============== - Code looks clean ✅ - Thinks about edge caes ✅ - No dry run for q1 ❌ - Somewhat slow ❌ - couldn’t complete code for q2 but close to it 🟡 General Tips: ============== - Follow this process : Read question → Write/understand test-case if not given → Discuss logic, speak of complexities yourself → Get a nod from interviewer (or re-think optimal solution) → Write code → Do a dry run → Give control back to interviewer - You gotta aim for first reading each concept, solving about 15-20 problems only related to each concept back to back, and then and then ONLY start your journey of doing questions randomly from leetcode. - Buy premium. Only do company tagged problems for companies you’re interviewing for. Try to do 100-150 problems at least, before you have your screening round. So much practice isn't to grasp concept but to polish you, and to make you faster at recognising issues and patterns and making lesser mistakes. - Prepare a google sheet where you log each problem you do, along with the time it took, and the extent to which you solved it. By extent I mean it can be a dropdown containing things like “Couldn't figure it out”, “Figured out bruteforce only”, “coded bruteforce only”, “figured out optimal but couldn't code”, “coded optimal but missed edge cases”, “coded perfectly” - Remember that when you're on this leetcode journey, you gotta solve questions as if you're being interviewed. You will first write down your logic in comments, check with test cases whether it works, if it works you jump to code. You write the code but don't click submit as soon as you feel it's done. You should do dry run with testcases (multiple) and make sure you're satisfied with code, and there aren't any syntax or logical bugs. Once that's all done is when you click Submit. Oh and also, you need to keep speaking throughout. You can take pauses in between to think, but in general you need to keep things engaged and communicate whatever you're doing and why. - Make sure to try problems again after a few days for which you failed or struggled (based on the sheet) - Check optimal solution always for even problems you submitted. But remember just coding them then and there would not help you. You need to revisit it after understanding optimal solution after a few days to see what you retain and how much you’re able to solve then. I hope these tips and the feedback helps you. All the very best for your prep. Feel free to reach out to me if you've got any more questions, or need more help, or even a referral down the line. Happy to help in whichever way I can. :)

Feedback about Quantum Wolf (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
I loved the way the interviewer explained feedback in a very detailed way!

Interview Transcript

Quantum Wolf: Hello
Serpentine Hawk: Hi.
Quantum Wolf: Hi can you hear me?
Serpentine Hawk: Yes, I can hear you well.
Quantum Wolf: All right. How are you?
Serpentine Hawk: I am great. Thank you.
Quantum Wolf: Alright. Yeah, you we're asking something. I interrupted you.
Serpentine Hawk: I see the blank screen that I think.
Quantum Wolf: Yeah, that's correct. You will be seeing a black screen in front of you. Yeah, that's fine. So alright, is this the first time you're interviewing on the platform?
Serpentine Hawk: Yes, it's my first time.
Quantum Wolf: Gotcha. Okay, cool. Let me just explain to you about the interface. So what you see in front of you is a decoder pad interface. Basically, it's a collaborative coding platform, where in whatever you're going to be typing, or I will be typing, it's going to be visible to both of us, even our cursors, or whatever we highlight, all of that is also visible to both of us. All right. Now, this is where you're going to code. This is just the plain text mode, but I could change it to different language, depending upon whichever language you'd like to code into. So there's also code execution available in this interface. But because Meta or Facebook does not allow you to run code, in the real interviews, we are going to not utilise this function and we're gonna just write the code, we're not going to execute it. Okay, the way you can test your code out is probably by doing a dry run, if you want to. Okay, now, what a couple of more things in case any audio issues happen. On the bottom right, you will see, first of all, you'll see a timer running there. Like it says around two minutes right now. So that's going to just track how much time we have been in the calls. The the thing next to that is having audio issues. If you click on that, you will see a telephone number. So in case we're having trouble connecting either side, we can just call up that number and connect to the call as well. So yeah, that's one more way. Yep, that's about the interface. Now, usually how mock interviews, go coding interviews is that I will try to keep it exactly how it is. I will try to mimic the exact real interviews that I take at meta now. The interview structure is like this for coding rounds. It's a 45 minute round in the real interviews, first five minutes again, for introductions, followed by 30 minutes of problem solving, followed by five minutes at the end for you to ask any questions you might have. In here for the mock interview, what I ended up doing is give you 40 minutes to solve the problems. There's no introduction just to preserve anonymity. And of course, once the mock interview is over, I will give you a verbal feedback. And I will once this call ends. So you will see a written feedback as well, for the same thing, okay. Also this entire call gets recorded. So you would be able to revisit the recording if you need to at future time. At any point in the future, okay. All right. Now one more reason why I get 40 minutes, even though in the real interview, it says like you get 35 minutes, like that's what you're going to hear from the recruiter is that if you keep your introduction, short, interviewers will keep their introduction very, very short. If you keep your introduction short as well, like when I say short, it's just one or two lines, right? Like if you're a PhD student you just say I'm doing a PhD, and I'll be joining as a new grad, or if you have X years of experience, you just say I have X years of experience. I'm currently working at this company working on this sort of stuff, and you end it in a couple of lines within 20 seconds or less. So that way, what happens is you get those five minutes of introductions almost almost in its entirety for problem solving. So you can kind of utilise that time. And you can end up getting close to 40 minutes for solving the problem. Okay. Yeah, which language you would would you be coding in today?
Serpentine Hawk: Swift.
Quantum Wolf: Swift. Okay. Cool. Cool. So, just just telling you beforehand, I have not coded in Swift myself. So in case there will be some things that I'm unaware of, I'll just ask you about that. Okay. And you can maybe explain those parts of the of the language Okay, now, do you want to give any background information as to? How of like, What level are you aiming for? Do you have any interviews coming up at meta? Any information you might want to share?
Serpentine Hawk: Yeah. Okay. I used to be an iOS developer for three years. And I have a seven years of experience in managing engineers for seven years in tech. I haven't been coding for last three years, but I started coding again back at last year in September, and for meta I want to apply for a partner engineer, because this position fits me. And yes, I don't have like, future interviews this month, maybe after two months, my preparation I will start applying for meta and other companies.
Quantum Wolf: Gotcha. Gotcha. Gotcha. All right. I'm just Okay. That sounds good. Okay, so is there any other questions you might have before we begin with the mock interview?
Serpentine Hawk: Do we need to more focus on optimal solution or? Or like the solution to be solved?In this kind of question?
Quantum Wolf: Right. So in most cases, you would want to go for optimal solution. But the suggested approach is that you can try suggesting whatever solution comes to your mind. Even if it's a brute force one, that's okay. And we'll see if we can go towards optimising it further. If not, whatever solution we can come up with. Let's go with that. Okay. I will tell you about, like, once the interview is over, I will tell you about what's the bar, at meta, and how our solutions judged, and How's it, how's it all thought about when when we actually judge the candidates at the end, okay. Sometimes even a brute force solution can end up working out in certain cases. But in most cases, the expectation is, first of all, that you aim for optimal solutions, or close to optimal solutions. And the second second thing is that in those 40 minutes, you are expected to solve two problems, not one. So So, so Yeah, usually you're given, like after 15 or 20 minutes, most likely, the interviewer will switch the problem, so that they can get signal on another question as well. Right. But if you're close to solving the first problem, maybe the interviewer will let you go on finish that one up and then switch to the second problem. But if you are way far from solving it, maybe interviewer will just switch the problem altogether. Okay.
Serpentine Hawk: Okay.
Quantum Wolf: All right. Cool. In that case, let's again let me give you the question first question this a question Can you see it I pasted it on line number three
Serpentine Hawk: I still see the black screen
Quantum Wolf: Wait, are you not? Is nothing visible in front of you is just black screen? Is that all?
Serpentine Hawk: Yeah. All the time.
Quantum Wolf: Oh, it's weird. Okay. Can you try refreshing it once?
Serpentine Hawk: I just refresh it right.
Quantum Wolf: Yeah, just refresh the browser tab. That's fine. You will get reconnected here. Yeah.
Serpentine Hawk: Okay, I will try.
Quantum Wolf: It's the same so in the black screen, can you see some text? Or is it just just black screen?
Serpentine Hawk: It's just a black screen. I don't know why. I see they haven't navigate issues. I see the timer.
Quantum Wolf: It that's weird. Could you try if you have another browser? Could you try it through that? Or maybe I don't know if it's an extension in your browser which is causing these issues? Because it's perfectly fine visible to me. The interface
Serpentine Hawk: I'm using Safari let me switch to chrome.
Quantum Wolf: Yeah, I will be good probably to switch to Chrome Yeah.
Serpentine Hawk: Hi, hi.
Quantum Wolf: Can you see it now?
Serpentine Hawk: Yeah, now I see the problem. I see the text.
Quantum Wolf: Yeah, gotcha. So this is the coding interface. Basically, anything I highlight should be visible to you, your cursor is visible to me. And it's like a collaborative coding platform. That's all, okay. Yeah, I've changed the language to Swift. So the question has been pasted on line number three, feel free to start with it yeah.
Serpentine Hawk: Okay. So let me read it given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. So we have test case 1, 3, 5, 7, 9.
Quantum Wolf: Yeah, what I would want is, instead of like me just writing out the output, I will confirm the output if it's correct or not, do you want to try and take a stab at writing what would be the output for this test case? Just so that we can understand if you have understood the question correctly.
Serpentine Hawk: Okay let me, do you have the same linked list group all the nodes with odd indices together followed by the node with even indices and return the ordered reordered list? So for example, in this case, 13579. So we're going to have one five or we're gonna have 3737, the index one and three. Three seven and then even index is zero two four is kind of then one. Am I right?
Quantum Wolf: No. So you're going slightly wrong. I think you've got the concept, right. But if you read the line number six, I think it will slightly change the output.
Serpentine Hawk: The first is considered odd, oh we have one, five?
Quantum Wolf: Yes. So it will be 1, 5 yeah.
Serpentine Hawk: Then you have five then you have nine and then we have three and seven, because they are all evens
Quantum Wolf: yes, yes, that's correct. So that's the correct output. Yeah. Now maybe you can think about what would be the way of solving this.
Serpentine Hawk: Okay, okay. So linkedlist is kind of challenging for me, but I will try it. I think here we can what comes, we can avoid? Can I write this here?
Quantum Wolf: Yeah, I think I think we'll be writing the code here outside the comments, but maybe we can discuss the solution first before you jump to coding.
Serpentine Hawk: So so what we can do for example, here's our node which is our input. And what we can do we can create kind of new even node. And let me just think what if we all switch to one for example, now we are at one. So one, the first we just leave it and then second. We see the see the three we put it back in there even node or so even node can be just I don't know, the beginning some kind of zero and it's next going to be three. And here. We check we can check if we have like next next for example five, we can just change the direction of it. So we put three in there even node. And we put this direction next node to the next dot next of the next so this will become this one and now we are at five. And also I think we can check for the next next 9 We have it and we have next one is seven. And just move seven. Not move just assign a new node to the even node this value seven, it will be like this. And here if we we have like next next value node so we can just change the next pointers to the next next is going to be 1, 5, 9. And here we check we don't have next one, and we don't have next next, or so we are in end so we can somehow break. Go out of their loop and just try to try to merge them. For example, if you don't have it's next. So we can do like node next, which is now nine it's not it's gonna be like even node next. It's gonna give it three. And when you when we will merge, it will look like thisone.
Quantum Wolf: Gotcha. Yeah, I think you're thinking in the right direction. What will be the time and space complexity in this case? For your solution,
Serpentine Hawk: The time complexity is going to be n, n is number of elements in our linked list because we just go for loop and space complexity, there's also going to be O of N and because we're using additional we're just using one additional node just to save even once.
Quantum Wolf: Right, gotcha. Okay, do you see any opportunities for optimization? Of either the time complexity or the space complexity?
Serpentine Hawk: I think we're okay with the solution.
Quantum Wolf: Okay, so
Serpentine Hawk: Uh about yeah just I think we're okay.
Quantum Wolf: Do you feel that, can is it not possible to do it without using the extra even? Even node linked list that you were forming?
Serpentine Hawk: Let me think in order to save space complexity, right?
Quantum Wolf: Yes
Serpentine Hawk: We can, we can just try to think about how can we maybe by changing the input itself can somehow get an output in this case 1,3,5 Seven maybe, of course, there are solutions that came to my mind. For example, in this final linked list. What if we go to the the tail, not the pointer to go which is going to be the nine one. So this is gonna be the tail. So if this one is like Final linked list, in order to get the tail one we just got one one more time go go through the linked list itself. The last one, we just started at the tail. And again we for loop from the beginning. And instead of for example, we have one, one is odd one and the next one is even three and instead of assigning it to the new, a new node, we can just assign it to the next of the temporary so they have this temporary point in in nine. You can just make it like temporary next. We can just make it three.
Quantum Wolf: Right, okay.
Serpentine Hawk: I pointed to three and you can point one to five and we're at five, do the same point to the seven and we can assign so now three is a tail. And after that we can just assign seven to the tail. So tail next is gonna equal to seven the new node and just you just remove it or just changing the pointers.
Quantum Wolf: Right. Okay. Sounds good. Looks good to me. I think you can try coding this one up. One more thing I think you just need to worry about coding the method. So you can assume that to your method a head node is past right. And that there is a linked list node structure which has a value and next point is available to you. So and you're directly given the head node and you can just work out the main logic of the function.
Serpentine Hawk: Yes, okay. And in this case, we have time complexity O N and space complexity. Just a one.
Quantum Wolf: Right. Yeah.
Serpentine Hawk: So yeah, you see a I done this logic? Let me start coding. Linked list is a bit challenging for me, but I will try I will do my best. Yeah.To give solution. So what we have here? We have node right, so this one is a linked list. So we just assume, right, this node is given, I have this node which is linked list?
Quantum Wolf: Yeah, you're given the head node basically, which points to one or the starting node. Right. Yeah. Yeah. And that's what given to you and you can just write down the rest of the stuff. Are there functions or methods in swift, Swift language?
Serpentine Hawk: Can you repeat one more time?
Quantum Wolf: So does Swift language have methods or functions?
Serpentine Hawk: Yes.
Quantum Wolf: Yeah. Maybe you can try writing this as a function right, which takes another parameter the head head node of the linked list.
Serpentine Hawk: Yeah, sure. So let's assume that we have a function which gives us head it gives us head which is linked list which has linked list. What we do we just return a new linked list in here in our function let me just start what we're gonna do here is just we do the pointer, it's let it be node and our node is equal to okay let me define as head and also I need to create the tail one tail which is for now it's equal to new actually, let me just do now let me find the tail one. I will go through the node for I can just you know I can do like this one I can say the tail is equal to node the first element and I can just for while tail is not equal to new. I will just assign nodes next. Equal tail next, tail dot next. So for example, now tail is equal to one and its tail will be equal to five because we just assigned on to tail next 5. For 1, 3, 5, 7 and it will assign to nine I think I need to write tail next is not equal to new and assigned it to nine so now it's nine if nine's next is equal to new it will just breaks. It means now we have our tail is equal to nine okay we have our tail now, we have our tail now and what is going to do is just go through the loop and just reorder the next pointers again I will use the for loop. Let me use creat the current which is going to be or node. The current is equal to one. Current will be qual to one. Yes now current is equal to one and we just need to just a little bit. Actually not for, this going to be while. Let me let me just put while loop but next to like way how when it stops. I'll just add quick this one so, for example now current is equal to what we're gonna do is just tail dot next is equal current dot next. Because current next is equal to three right now and we just asssign that nine dot next let me just write right here. So for example we have our tail this one is our input I just need to move this okay. Nine is our tail now. We have current is one have our current is one. Now what what do we have our current is one so we have we say that our tail next is going to be equal to three is going to be equal to call it next which is three and the current itself. Next will be current. Next. Dot next. So it will be equal to five. And now our five is current.
Quantum Wolf: No, how is it five current? Yeah, okay.
Serpentine Hawk: Yeah, yeah, we just make it like current equals just current next, now five is current, right. And again, it comes here it's now our tail is also we need to do the same to this tail. Tail equals tail next. Yeah, now our tail is equal to three. Yeah, and we go back again. And we are now at five. So our tae next is gonna be current next, current next is seven. So I will just make it seven. Tail is now equal seven. Tail is equal to seven. And the current equal current next next. Current next now is goes to nine. And current is equal to nine right now, and actually here we need to stop. Right? We need to stop Let me see if we can I think we can. Maybe I have two solutions here and I think I will ask you to help me with this while looking for a tail actually we can save the count counter and just divide it by two and we'll have divided by two yeah and then we have counter here for example, just going there like that time or we can just create the, create the one like copy of the tail and just check if current will be equal to that tail like my value. But I think the counter will be better because we're going to have values equal right inside our linked list.
Quantum Wolf: Yeah, we could have values equal inside our linked list.
Serpentine Hawk: Let me create the counter, was equal to one and here we can use not while but we can use for loop, i in zero and the counter divided by two let me check this okay.
Quantum Wolf: So just wanna ask something what does this double dots do or what do they mean?
Serpentine Hawk: It means so it will iterate from zero until counter divided by two.
Quantum Wolf: Gotcha. Gotcha okay
Serpentine Hawk: Okay, okay, okay. Okay so we'll go through for example 1, 2, 3, 4, 5. 5 divided by two is gonna be two and zero by two zero not including zero one two. Should include nine or no? No, yes. No, not including because we don't need to do anything with nine this should be right. This should be right and indent I will just return the node. And because node will point. I will change it. I will change the current one yes. Yes, they're done. But there are some you know in swift we have this. We also need to check for constraints. For example, it has to be equal to new or equal to one we just we just returned the way it is. Yeah. Let me check it. Actually, we put question mark, you know that because it can be new. And we check if had is equal to new or had dot next is equal to new. We just return new in this case and then tail. Yeah, we'll just put question mark here question mark. Because all of them can be newable. Current dot next and current. Ah yes and also this can be new yes yeah I think we are done.
Quantum Wolf: Cool. Yeah looks good to me as well I think let's jump to another question
Serpentine Hawk: yes
Quantum Wolf: Okay. I'm just pasting this question after the first question is solved. So on line number 80, 79 or 80.
Serpentine Hawk: Okay, 80 right? Given the root of a binary tree, return an array of the largest value in each row of the tree. So give the root of a binary tree return an array of the largest value in each row of the tree. One okay, I think I got you so the first row is equal to one because it is the itself at the second row we have three and two and the largest is three. The third row is 5, 3, 9. And the largest will be nine and that's why we need to return array of integers is nine. Yeah, yeah, we can use BFS here in order to traverse and for the each line to get the maximum yes what I gonna use yes as we use the BFS
Quantum Wolf: sorry, depth first search or breadth first search
Serpentine Hawk: I'm talking about breadth first search
Quantum Wolf: gotcha okay cool.
Serpentine Hawk: Because we need the level, to look for levels yeah. I will use the BFS. BFS what I'm going to do is just for example, I will take the one is a three nodes and I will have the temporary array which I will put its children for example three and two and here is only one like this, the size of it is one yes, so our next array is going to be three and two and inbetween these two, I will get the maximum get the max. For example, if I get three I will put it as a max and I will check the second one and get the maximum of them in this case I'll get the max three and I will add it in the into result so I will have the result array there is the one and there's new three and get the max which is here and I will put it in the result array. And this this array. I will gonna loop through this array three for example in 3 we have children five and three, there's gonna be five and three and go to the two and its children is nine. So we have three of them and three of them and what do we have the maximum so is nine and I will just put it in the result now the result is nine and yes as we don't have for example even as we'll go through each of them so five has no children three has no children. Nine have no children. I just don't add anything in the result and I can return the result. Yeah, this is the solution.
Quantum Wolf: Okay, I have a question here. So how Okay, let's talk about the complexity first was the time and space complexity.
Serpentine Hawk: Time complexity is O of N and space complexities also O of N because it goes through each element, space complexities also O of N because we're gonna Yes, because we keep it in the array. Did you have any questions?
Quantum Wolf: So, uh, how are, so you're keeping only one element per level right? So why could it be O of N? can we justify that for the space complexity?
Serpentine Hawk: Oh, yes. Actually it might be it's the worst case actually the worst case is less than n
Quantum Wolf: Okay? How is that
Serpentine Hawk: Is less than N because for example, in this we have this element but we for example, at first is it one and then second two and three is going to be less than n I know we can write this as a log (N) because it wont keep all the elements
Quantum Wolf: Okay, why would it be log of N can you try to justify that?
Serpentine Hawk: Mhm in case we have like, a very big amount of for example, can I show you just, for example, I just had a Promax approximately write it again but in case we have, for example, many many elements going down. But the lowest level or the level is which has big amount of nodes is gonna be less than the number and approximate, I can just say that it's gonna be just the log N is more than a one but less than O of N.
Quantum Wolf: Okay. Is there like? So, have we taken any assumption about what kind of binary tree would this would be?
Serpentine Hawk: What kind of binary tree?
Quantum Wolf: It's just a binary tree, right? So,
Serpentine Hawk: yes, it's just a binary tree,
Quantum Wolf: Right, so in the worst case with n elements, how many levels can it have?
Serpentine Hawk: Actually, in the worst case I feel we don't have news we have like all the elements fully we have all the elements fully and in this case, for example, we have 1, 2, 3, 4, 5, 6, 7. 7 elements, we have three levels. Three levels and the length, the maximum length is going to be like four. Four, if we have one more level, it's gonna be eight. We have one more we have 16.
Quantum Wolf: Okay, anyway, I think I got my answer. So perhaps you can jump to writing down the code for this.
Serpentine Hawk: Yes, okay. Do you have time?
Quantum Wolf: Yeah, we have another five to six minutes so you can go ahead and code yeah.
Serpentine Hawk: Okay, let me start just here. So we have this function that will for example, let it be get max
Quantum Wolf: why is this showing comments
Serpentine Hawk: maybe like this one?
Quantum Wolf: Perhaps you can write down the code? Yeah, you can write it there.
Serpentine Hawk: Yes. For example, we have a function let's say to get max. We do have we're gonna have we then have lightning callers node which is going to be a tree node and it will return integers because they need to get maximum of it in this case let me create the actually not integer but the array of integers they have a result which is an empty array of integers we create we also there we can we can check first of all if node is equal to nil to reduce to to return empty array return empty we can I think it's also better to check if there's only one element but I will do it latter maybe we have this array of nodes. Tree node it's array is our first node it consists of the node itself we can do var size is equal to array dot count we need to size in order to itterate. Size but also just to like maybe counter just to count just or just index or just to count to go to see I need to go through it a while counter. And here what we gonna do I will just create this temporary array which one is empty this temporary array is tree nodes. This one temporary arrays down here what what I got to do this is just as we use this not counter but index I think it's more understandable. So array index so what I'm gonna do now, so I have this while loop that will add a that'll loop this array once because array is going to have this array of nodes and here I create a temporary array in order to save here children children to the level here in array index so the question is to not have on the left right or just array of children's in this so the tree node it it's just mine just has left and right. Let me create the max value here bar max value which is equal in the Max. Can array temp array we append this. Okay wait we have array of node so for now is we have only one on one array index we have its left and they have its right and we need to save it in a temporarily. So we temporarily array we append left and temporary array we append also the right for example now we have one right it was 1. So we have 1 it says three temporary array it appended so let me do like this one just for now temporary array left and right so it appended in the temporary array one second time so we don't have I think we just need to create one also in a temporary array while. Let me think but actually should be two whiles one so it added temporary array left and right so it added let me just little bit think okay. It adds three and two and exits. What are we gonna have here? Yes, array. Is Equal temp array. Size is equal to how this might look here. And the size is equal.
Quantum Wolf: Okay I think I got a point. Let's stop here, because we have gone a little over time now. Okay, cool. So before I give you the feedback that I've written now, how did you think you performed in the interview?
Serpentine Hawk: I think I'm kind of slow. I feel like I'm slow, like I can do like, more faster. But I performed it kind of slow. But I'm sure I could solve both of them. But I need to do faster.
Quantum Wolf: Yeah. So I think yeah, that kind of covers up even what I've written now. Generally, you did not do badly or poorly in any way. If this was the screening round for meta, you would get in for sure. Right you would get a hire signal to go on for on site rounds in the onsite rounds, it might still give you a hire signal, but not with very high confidence. Because second question we could not complete. And at the same time for both the questions. There was no dry run done to kind of check for all the cases, right. So those are the things that primarily got missed. And those things primarily came from you being a little slow on the coding front. I don't think you're slow on the on the problem solving side of things when you have to like the thinking about the solution part. You're you're pretty pretty good there. You're pretty fast there. But when it comes to actually coding it up, I think that's where you get a little slow right now. It can it can improve with practice. That's that's how it improves the coding speed improves when you solve a lot of problems. Okay, now let me just give you feedback under each category. So the first one is communication. So here don't have much of problems, you're very clear in your communication, you also use the comment space very efficiently in describing the solution. It was good that you mentioned at the fact that you are a little weak in linked list. You know that such a thing, if it if it's there for any particular topic, gives you two advantages as a candidate one, if you end up doing well, on that question, it's positive signal for you. It's a good positive thing for you. Secondly, interviewer will try to make sure that for the second question, they do not choose it to be linked list again, just so that they can get more idea about maybe other other topics, which might be a strength areas, right? So. So it's good to mention something like that, and just be very open and honest in the interview, okay. Then, it's also good that when you're coding up your solution, you kind of talk through it, you describe what you've done, or what you're doing right now. And you can kind of keep the interviewer engaged. So those are all good points. One thing that I would suggest which caught me off guard was when I was asking you, in the first question, initially, you had come up with the solution of which uses time complexity O of N and space complexity O of N, but now here, when I say that, is there any opportunity to optimise this? You spoke that no, I think this is okay. Or we are okay with this. So that's usually not, that's usually not a decision that a candidate takes, right? If an interviewer is asking you something like that, they are basically hinting you to move in a more optimal direction. Okay. So you need to think of as a more optimal solution, or you need to prove that there cannot be any more optimal solution. Right? So if you basically proven to me that, okay, it cannot go better than O of N and space complexity, then I would be fine. But because this one could, you have to now think about that optimal solution, right. And if an interviewer is pushing you towards optimal solution, they, they're always aware about the time constraints as well. So they know what they're doing, they will try there, they basically know that, if they feel that you'll be able to solve it in another five minutes and or we have enough time to, for you to kind of take a stab at it, only then they will try to hand you towards going for it. So I think just try to be more cautious with your words when you're when when interview is hinting you towards going for a more optimal solution. Technical knowledge side are some good points were that you knew about Linked list. You knew, what breadth first search you were able to answer question about time and space complexity. In the first question correctly. In the second question, I think you missed out on the the space complexity part with the breadth first search. So it will not be O of log N? The initial answer was correct O of N, but then you are not able to justify that. The reason is in the second question, it just says that it's a binary tree, right? A binary tree can be completely skewed on one side also, where in basically every node only has a left child. And your your tree is basically like a linked list in a way. Right. So if that's the case, then every level is going to have just one element. In which case your you your output will itself take up O of N space. In the other case, also like if you're thinking about a perfectly balanced binary tree, the last level is like at any point you use this array to the the temp array to keep the children right of a particular level in the in the in your temporary so that you can use that as a queue for breadth first search right? So
Serpentine Hawk: Yeah yeah queue.
Quantum Wolf: this temp yeah this temp array or the queue will add max hold the maximum number of elements in a particular level. Right. And if you think about a perfectly balanced binary tree also similar to the one that we had here, even though this is not perfectly balanced, you will have as you were saying the four elements and in if you have three levels, right, or eight elements if you have four limits. So this is again not log of n situation this is more like n by two. This is close to n by two like the total number of elements you have seven and what you have in the last level is four is the total number of elements you have is 15. The last level will have eight elements. So it's always close to end by two So in my tool will still end up being ordered of N. So that was the justification that I was looking for there. Which got missed problem solving skills side, you were able to find the proper brute force and optimal solution for the first question, you were able to find the optimal solution. For the second question as well. I did not have to give you any hints for this. So that was the good part. So no problems there on the problem solving skills side, coding skills side, your code looks looks to be clean, majorly judging the first question, because second question was not yet complete. All the second question also seem to be going in the right direction. You think about the edge cases as well. So that's good. You think about null cases, all of that is pretty good. The things that got missed was in the there was no dry run done, and no other test cases that you tried out in the first question. So you need to think about that, you will end up taking a few minutes for that sort of thing as well. Right for each question, and you need to do that you need to come up with couple of test cases on your own. And just try to do a dry, run yourself for them, right. And remember, when you're doing a dry run, you're not doing, you're not writing down a case, and then just thinking if the code will work fine. And just doing it in your head. The entire idea of a dry run is that you process the code line by line, and you forget that there's a logic in your head, you have a code in front of you, you will start like if you had the test case, linked list, then you will start annotating that okay, head here points to one and head is not nill, and head dot next is not nill. So we will go to node node will be set to one tail would be set to one. And you will kind of do an inline annotation of each variable. And that's how you're going to process the entire code. So for example, inside, while Tail dot next is not nill counter is equal to one. So you will say that counter will first be one, then it gets changed to two then gets changed to three, four, and so on so forth. You do that sort of a dry run, where you're just processing the code as a compiler of sorts. The reason for dry run doing, doing it, doing it like that is just so that you can identify if there are any logical issues that you've made in the code, right? If you just run the test case, through your head, the logic in your head is always going to be perfect, right? That's the reason you ended up coding it up. So we've already discussed that the logic is correct. So what happens is that the entire purpose of dry run is just to showcase that your code is also perfect. So you should try to do that dry run, like that's why I just kind of summarised it on line number 34 to 45, just to kind of give you an idea. So you can take care of that. And yeah, overall, the speed seems to be slow compared to the average candidates who pass around. When I say pass around, I'm sorry, let me let me put it like this average candidates who are able to solve both the questions, right, compared to them, the speed of coding is a little slower. So that will improve with practice. Usually candidates who nail both the both the questions in the round, on average, have solved 150 to 200 questions from leetcode. Right. And that is consistent practice. So they they're usually solving questions every day, even if like three to four questions every day. But they are they're putting into practice every day. Right? So I try to have a streak going on like that wherein you you, regardless of the day, regardless of where you are, you try to code at least four questions a day, four to five questions a day, and try to reach a number like 150 to 200 as possible. If you're already at that number, then try to make sure that there are no breaks that happen in between, right. So I think that will take care of making sure that your speed increases. And other way to do this is that you can try noting, like logging it out in an Excel sheet or a Google Sheet. Like every question that you solve, just try to write time it out, right? How much time did you take to solve that question? What level of difficulty it was? And to what extent you were able to solve that question like were you able to solve it with the optimal solution with all edge cases handled, or you missed out on some edge cases, or you just came up with a brute force solution, or you were not able to solve it at all right? Forming this sort of a data gives you the power to do very good analysis. Maybe at the end of every week, and this analysis can give you a lot of insights on your path to improvement, right? For example, you can get things like how much how many questions are you able to solve in the last week? Is that number improving from the week prior to that or not? Similarly, how much time did it take for you to solve medium questions, average time that you took to solve medium level questions or hard level questions or easy level questions? Has that reduced from the previous week or not? Then things like were there more questions that you were able to solve optimally than the amount of question that is solved with brute force, compared to previous week, right? So you will see a difference. If you keep doing this, and it's usually good, because it gives a confidence boost also, that you're you're moving towards the right direction, it's not just going waste, right? Because it's real data in front of you, which is speaking all of this. So I would suggest doing something like that, that will help you know, what are the what are the things that you're lackingin and also, when you're practising questions from leetcode, or whichever platform tried to solve them, just like you're doing an interview. Now you know how it's going to be in an interview, right?
Serpentine Hawk: Yeah
Quantum Wolf: So you try to speak it out while solving the question, try to write down the solution and comments, speak of its time and space complexity, then write the code after doing the code, do a dry run, do not just click Submit and let the leetcode compiler take care of finding the edge cases, right? You try to do dry run, you try to think of test cases, once you're fully satisfied with your solution, then only click on Submit. Yep, so that's basically all the feedback that I have, we could not get complete code for question two, but you were pretty close to it. So I feel if you had another two or three minutes, you would have completed it. But again, dry run would have been missed. So it's not a perfect interview round by any means. But for a screening round, this is good enough. Because from scanning around, we're just looking for positive signals to see if the candidate is worth for an on site interview. So for screening on this was good for onside round, also, this can still get a hire signal, probably with a low confidence, though, or with an average confidence, not with a high. Right. But that's where it stands, it's not a bad interview at all, you were able to get close to solving two questions.
Serpentine Hawk: Okay I got you.
Quantum Wolf: All right. Yeah. So that's how things I just in general, if I have to give you an idea, yeah. Sometimes, if I, one of the questions you had asked was brute force versus optimal. So it's like this, let's say, you were able to only solve the first question in a brute force way, right? And when we switch questions, because your linked list was weak? In the second question, you immediately were able to solve it in an optimal solution, then you will still get a higher signal, right? Because you kind of mentioned that link list is weak and brute force there is okay. But for the for the topics, you do perform very well. That's one way. The other way is, perhaps if there's a hard question that's thrown at you, right, not a medium level question. If you're able to solve that and brute force way, completely, and then also take a stab at another question and solve that also, almost completely. The other question will never be hard, they you know, never going to get two hard questions in a meta interview. So in that case, again, you will get through because the first question was hard. So it's not always easy to come up with optimization in time. So these kinds of cases, brute force solution works fine. Sometimes, if you're low on time for the second question, and you will just end up solving it with a brute force approach, just to make sure that you have given a solution. In that case, also, you can you could get a hire signal if you have performed very well in the round otherwise, right? But do note that if you're solving both the questions with just a brute force approach, that's not going to get you a hire signal. Right? So you need to do well in at least one of the questions and maybe the other question can take a little bit of a hit. But these these, any sort of a hit will make sure that you do not get a hire signal with a very high confidence it will be more like an with an average confidence or it becomes with a low confidence. So that's how it Okay, so that's all I had any questions that you have.
Serpentine Hawk: So I will get the feedback on my email right?
Quantum Wolf: Not on your email. So once this call ends, you will be taken to a screen where you would have to fill in feedback from me you can fill in very honestly feedback as to how you felt this interview was once you fill that feedback form up, your your feedback will be visible on the website as well. Right? And in the history, you will be able to see this mock interview and you can always go back see the feedback or replay the entire clip if you want to. Okay.
Serpentine Hawk: okay, okay, I got you. Thank you so much. All right clear and helpful
Quantum Wolf: All right cool happy to help and all the very best for your preparation
Serpentine Hawk: thank you so much
Quantum Wolf: All right Have a great day bye bye
Serpentine Hawk: bye bye you too

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.