Community stories
programmingby Stan · 442 words · 185 views

Reverse a linked list

Third round, whiteboard, a very kind interviewer called Pradeep, and for some reason you're thinking about your dog.

You've been asked to reverse a linked list and you are, somehow, thinking about your dog. It's the third round. The first two went fine. Behavioural, then a systems design thing where you drew boxes and arrows and the woman nodded at intervals that you chose to read as approval. Now it's a room with a whiteboard and a man called Pradeep who has a laptop open and is being very kind, which is worrying. "Take your time," Pradeep says. You know how to reverse a linked list. You have known how to reverse a linked list since you were twenty-two. You have never once, in nine years of professional software development, needed to reverse a linked list, and you have a theory that nobody has, and that the whole exercise is a kind of secret handshake, and you would like to say this to Pradeep and you absolutely will not. You draw three boxes. You draw arrows between them. Your marker squeaks. The dog thing is that you left her with your neighbour this morning and she gave you a look through the window like you'd sold her. "So we'll need three pointers," you say. "Previous, current, next." "Sure." You write the loop. You write it correctly, you're fairly sure, and then you look at it and it looks wrong, in the way your own name looks wrong if you stare at it. You talk through it. You walk the three boxes through the loop with your finger. "What happens at the end?" Pradeep asks. You look at it. "Previous is the new head." "Yep." "Should I..." "You could write it up as a function if you like. Or we can move on." You write it up as a function because you've already started and stopping feels like flinching. You add the edge case for an empty list. Pradeep types something. "Cool," he says. "Can I ask you something not on the list?" "Sure." "What's the last thing you built that you were actually happy with?" And you tell him. It's not impressive. It's a little internal tool that turned a forty-minute manual process into a button, and the person who used to do the forty minutes sent you a message with just a heart in it. You realise you've been talking for three minutes. Pradeep hasn't typed anything. "That's good," he says. "That's the kind of thing." You wipe the whiteboard on the way out. The linked list goes in three swipes. Downstairs, in the lobby, you check your phone and your neighbour has sent a photo of your dog asleep on his sofa, no look in it at all.

How hot is it?

Not rated yet
#interviews#whiteboard#second-person#career

Themes: job interview · linked list · programming · interview questions · software development · career advice · programming interview

Comments

Loading comments…