haoel / leetcode

LeetCode Problems' Solutions
17.58k stars 4.91k forks source link

Find a bug in searchInsertPosition.cpp #7

Closed pezy closed 9 years ago

pezy commented 9 years ago

Have a look at: https://github.com/haoel/leetcode/blob/master/src/searchInsertPosition/searchInsertPosition.cpp#L28

int mid = low +(high-low)/2;

would occur overflow. try to change to this:

int mid = (high-low)/2;
pezy commented 9 years ago

Sorry, My mistake.