Files
Algorithms-snippets/Searching/binary_search_normal.cpp
2023-11-12 19:18:10 +05:30

14 lines
193 B
C++

//Binary Search Normal
int low = 0 , high = n , ans;
while( low <= high ){
int mid = low + ( high - low)/2;
if( check(mid) ){
ans = mid;
low = mid + 1;
}
else{
high = mid - 1;
}
}