The Judge Group interview question

Live coding of Java algorithm problem