News for hackers. Stuff that matters.
Re:Fast midpoint between two integers without overflow by lesuorac on Wednesday December 07, 2022 @11:21AM (#33896207)
> This is an excellent interview question (I used it a lot).

Is it though? It just tells you if they know the trick or not. At that point you might as well have them fill out a form and use the score from that to hire/no hire.

It doesn't tell you if they understand what RAM is or storage (HDD/SSD/etc) or the various buses on a motherboard or pretty much anything about how a computer works. For the example given in the article, it's pretty rare for (a+b)/2 to overflow since the default ints end up being 32 bit (article calls out 64bit tbh) and your parameters are [-1000,1000].

---

> 90-95% of engineers don't even see a problem with (a + b) / 2 until you tell them about the overflow, let alone find a solution for it.

In my experience a similar percentage can't write a working DFS which I think is much more work related than midpoint.

There are no comments on this comment yet.