Files
Algorithms-snippets/Searching/binary_search_normal.cpp
2024-04-10 15:36:18 +05:30

14 lines
206 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;
}
}