Monthly Archives: April 2013

Programming Interview Preparation: Whiteboard

In a month you will have programming interview at elite Big Co or rocket-ship startup. You are reading CLRS, Programming Interviews Exposed and even coded 20 problems. You are confident and things are going well. But wait, aren’t you expected to solve programming tasks on a whiteboard?  

In a month in your interview loop not only will you meet sharpest engineers, A+ players who consistently want to raise the bar and have no mercy towards B and C players, but your code will be scrutinized, you need to deliver solution under pressure and on time. On a whiteboard.

Whiteboard coding isn’t programming per se, it’s a sport. Every second counts, every line of code is important and you are required to show your best. Get ready, read on and you will walk on water during your coding session.

Of course, you need to practice. Practice a lot. Not alone, but with a real interviewer.

Stage 1: Get Familiar with Whiteboard. If you are lucky enough to have a competent friend or mentor – ask him or her to interview you at least twice a week. Do a mock interview on a whiteboard as often as possible. You first goal is to get a feel what it is like to have several whiteboard coding sessions a day. At this stage you need to become absolutely comfortable to code on a whiteboard, it should be just as easy as typing on a computer.

Stage 2: Become Fast Whiteboard Coder. I mean really fast whiteboard coder. When an interviewer asks you to solve the task which involves binary tree, you don’t want to ask too many questions. 30 seconds and binary tree node should be on the whiteboard. Not only you saved 10-15 minutes of interviewing time that you will use towards solution, but you also impressed the interviewer since past 5 candidates just started to warm up at this point.

Stage 3: Become a Whiteboard Master. We are not going to talk how to solve your task here – you are a rock star engineer, why do you need any help with that? At this point you are polishing your skills:

  • Buy thin markers and use them during interview. They will help save expensive whiteboard space and your code will be much easier to read. Remember to bring several markers to the interview, you may forget to put it back in your pocket if the interview was very intense!
  • Use whiteboard space wisely. Practice and make sure that your solution is not stretched all over whiteboard.
  • Time yourself. Make sure you really know how long it takes you to implement data structures, loops, error handling and standard solutions such as traversing linked list.

You will be much better off even if you will practice in complete solitude, but best results are achieved with a ruthless interviewer. Practice, don’t rush and you will succeed.

PowerShell: capturing output to log file and console

Recently I had to redirect full PowerShell session to both console and log file. Full means both stdout and stderr needs to be redirected. Working code is worth thousand words:

 

$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"

$OutputFileLocation = "C:\output.log"
Start-Transcript -path $OutputFileLocation -append

Write-Host "This will go into output.log"

# redirecting both STDOUT and STDERR (2>&1) to transcript:
robocopy.exe C:\ D:\ readme.txt 2>&1 | out-host

Stop-Transcript

 

Line 11 deserves additional explanation. Due to a PowerShell bug 315875 output from native applications will not be captured. That being said, the workaround is to combine stdout and stderr and redirect it to a out-host.

The only remaining limitation is that stderr will be interpreted by PowerShell as error (and rightly so!) and thus printed out in red. While it is a little annoying, your output log doesn’t have colors 🙂

 

Programming Interview Preparation: Books

I am frequently asked how to prepare for a technical interview at top software companies in the US. Having been on both sides of programming interviews, I can say that one of the keys to successful interview is to start preparation early and have focus.

Maintaining focus during preparation is difficult as there literally thousands of programming problems to solve. However, I will keep the list of must-read books short as they will prepare you for 99% of all programming interviews. Here are the books per area:

Programming Interviews

Algorithms

Computer Architecture

Software Design

Ideally you would read all of them and complete most tasks, but if you are on a really tight schedule, both books from Programming Interviews category will get you started and the rest can be used as a reference.

Good luck and raise the bar!