16Counting, Measuring, and Ordering Puzzles

In addition to technical and programming problems, you sometimes encounter brainteasers in your interviews. Brainteasers are mathematical and logical puzzles that have indirect relation to computer programming.

Historically, many interviewers have thought that brainteasers are useful in assessing problem-solving ability—perhaps the most important job skill for a programmer—and brainteasers have featured heavily in programming interviews. We have generally believed that performance on brainteasers says a lot about how much experience you have with brainteasers and very little about whether you’re a good coder. We’ve been pleased to see that many leading companies (including Google, once infamous for its brainteasers) have asked interviewers to refrain from using these kinds of problems and to focus exclusively on technical and programming problems.

Nevertheless, you may encounter brainteasers in your interviews, particularly if you have a nontraditional background or limited coding experience, because interviewers may believe these puzzles assess your ability to think logically and algorithmically. Knowing a few simple techniques for tackling these problems can dramatically improve your performance. This chapter and the next discuss these strategies and illustrate their application on a representative sample of brainteasers.


You should keep in mind that the solutions to brainteasers are almost never straightforward ...

Get Programming Interviews Exposed, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.