There are merits and disadvantages to including any sort of programming challenge in your interview process. The argument for something like a FizzBuzz challenge is that a surprising number of programmers can’t actually do that, and it weeds out the worst candidates and the liars.

Gareth was interviewing someone who purported to be a senior developer with loads of Java experience. As a standard part of their interview process, they do a little TDD based exercise: “here’s a test, here’s how to run it, now write some code which passes the test.”

The candidate had no idea what to make of this exercise. After about 45 minutes which resulted in three lines of code (one of which was just a closing curly bracket) Gareth gave the candidate some mercy. Interviews are stressful, the candidate might not be comfortable with the tools, everybody has a bad brainfart from time to time. He offered a different, simpler task.

“Heres’s some code which generates a list of numbers. I’d like you to write a method which finds the number which appears in the list most frequently.”

import java.io.*;
import java.util.*;
class Solution {
  public static void main(String[] args) {
    List<Integer> numbers = new Vector<Integer>();
    numbers.add(5);
    numbers.add(14);
    numbers.add(6);
    numbers.add(7);
    numbers.add(7);
    numbers.add(7);
    numbers.add(20);
    numbers.add(10);
    numbers.add(10);

    // find most common item
    for(Integer num : numbers){
      if(num == 5 ){
        int five += 1;
      }
      else if(num == 14 ) [
        int foue=rteen += !:
        }
   }
}

Gareth brought the interview to a close. After this, he didn’t want to spend another foue=rteen minutes trying to find a test the candidate could pass.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!