3 ms·
Many people implement it wrong. The best programmers know how to check their work, and will be asked during the interview to check. Who doesn't know that (x +
by jrockway 15y ago
Many people implement it wrong. The best programmers know how to check their work, and will be asked during the interview to check.
Who doesn't know that (x + y) / 2 can overflow?
But the people who you really want to filter out have no idea or intuition that a problem can be solved by slicing it into two. That's the key idea behind binary search (and indeed, much of computer science).