from comments on leetcode
mid = (start+end)/2 could result in integer overflow.
mid = start + (end-start)/2 could also result in integer overflow if the start and end are two extreme numbers.
The best way to handle this is to use
mid = end - (end - start) / 2;