azl397985856/leetcode

关于二分法中查找中间点索引的算式

booltcher opened this issue · 6 comments

const mid = Math.floor(left + (right - left) / 2);

在所有示例中都是这样计算中间点索引的,不过不应该是下面这样吗?

const mid = Math.floor((left + right) / 2);

抱歉,是我理解错了。

是为了防止溢出