Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sort_search_problems/first_occurrence_binary_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
int low = 0;
int firstOccurrance = -1;
while ( low <= high ) {
int mid = (high + low) / 2;
int mid = low + (high - low)/2; //avoiding overflow
if ( key < vec[mid] ) {
high = mid - 1;
} else if ( key > vec[mid]) {
Expand Down