Binary Search Template for C++
#define int long long int
int low=0,high=1e13,mid;
int ans=1e18;
while(low<=high){
mid=low+(high-low)/2;
if(helper(v,mid,m)){
ans=min(ans,mid);
high=mid-1;
}
else low=mid+1;
}
cout<<ans<<endl;
0 Comments
If you have any doubts/suggestion/any query or want to improve this article, you can comment down below and let me know. Will reply to you soon.