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
4 changes: 3 additions & 1 deletion Binary Search/Book_Allocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ int findMinPages(int *books,int n,int k){
int ans = INT_MAX;

while(s<=e){
mid = (s+e)/2;
//Mid should be considered like this in order to avoid Integer overflow that can be caused.
// If both s and e are INT_MAX. If we take mid = (s+e)/2 , this will cause overflow and give WA.
mid = s + (e-s)/2;

if(isValid(books,n,k,mid)){
ans =
Expand Down