Killer Interview Question: Code An Efficient Way To Calculate Puddle Sizes

Many of the killer interview questions we've featured before would apply in any job. For developer roles, you'll often be asked to write code to solve a particular problem. As student Michael Kozakov discovered when being interviewed by Twitter, the kicker is that you have to write not just functional code, but the most efficient code.

Kozakov was asked to write code to calculate the amount of rain that would catch between a group of buildings with arbitrary heights. He came up with what he thought was an effective method, but his interviewer promptly pointed out that while that approach would work, it required two passes through the data, and it should be possible with just one pass. After the interview was over, Kozakov realised that the approach he had coded wouldn't actually produce the right answer in all cases.

Kozakov's blog post runs through the full mathematics if you're curious. The bigger takeaway is that advanced developer jobs require both imaginative thinking and sound mathematical skills, not merely experience with a specific platform.

I Failed A Twitter Interview [Michael Kozakov via Business Insider]



    Seems very easy within a finite area, where the 'drops' are non-irregular shapes as based on the image..

    But then - that's what an interview programming question should be I guess, something which just proves you know the basics and have the logic to figure it out within a timeframe.

      But on that note as well, he did prove that he showed the basics, which is why I find some of these questions a bit unnecessary. Much like the 'why is a manhole round' question, they're good at showing the thought processes, but then people get all smug after hearing a non-optimal answer.

        Completely agree. Very subjective. I've had many really useful changes on github denied because they didn't 'like the look of that particular API style'..

        Last edited 20/12/13 4:48 pm

    I had to build a forecasting and sales history reporting tool in excel as part of an interview.

    The hard part wasn't the task itself, it was having to write VBA code on a different laptop. I kept on stuffing up simple text because I wasn't familiar with the keyboard.

    But yea, I got the job so I guess they liked it.

Join the discussion!