mid = (low+high) / 2 vs mid=low+ (high-low) /2
In binary search algorithm implementation most of us including me we get used to calculate mid value by mid = (low + high) / 2 which is ok and fine in most cases but during our readings and research sometime we found another formula mid=low+ (high-low) /2 but we did not pay much attention to the difference.
The first time to knew the difference for me was during solving one of the problems in leetcode and I kept getting Time Limit Exceeded without knowing where is the problem until I tried the mid=low+ (high-low) /2 formula.
I recommend to try to solve this problem on Binary search on leetcode then go to this awesome stackoverflow link to read in details difference.