There's not much to say about the question itself — it's just malloc. But the interview process wasn't quite what I imagined, so I'm sharing it for everyone's reference.
The interviewer's background looked very, very strong.
After reading the question, I went with the standard interview-report format and started with first-fit. The interviewer pressed for a ton of detail — what data structure to use, how to merge left and right, what algorithm to find the insertion point — I had to explain everything very, very clearly.
After that, he immediately asked about time and space complexity and then had me optimize it. I brought out the best-fit solution, which needs an extra sorted index, and again had to clarify the logic and the data structures used. 75 minutes looks like a lot, but all the time went into discussion.
Different from other interview reports I'd seen before, he said I could use any advanced data structure I wanted, whatever was convenient. Still, when it comes to actually writing it, I'd suggest preparing all of them in advance so you don't scramble.
I implemented first-fit first and then was asked to write tests, but the funniest part was that CoderPad crashed and I couldn't test anything at all. I ended up spending a long time debugging CoderPad itself. In the end the interviewer and I found a small naming bug together, and he also followed up with a question about how I would design the tests — that one caught me a bit off guard.
With about 25 minutes left, the interviewer felt there wasn't enough time, but said I could try writing best-fit. I wrote it quickly and then spent a few minutes going through the code myself to avoid the mistake from the previous question, but I felt like the interviewer had completely stopped caring by that point. In the end he didn't have me run the tests, and we spent the last ten minutes on questions.
After the interview I basically felt like it was dead and I was just waiting to get rejected. I followed up and was told it was positive and I was moving on to the next round.
Discussion
Loading comments…