You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: When the current student's page sum exceeded mid, the code incorrectly added the book's pages to pagesum instead of starting a new student's allocation. Impact: Incorrect allocation logic caused feasibility checks to fail.
Binary Search Midpoint Calculation:
Problem: mid was calculated as sum + (end - sum) / 2, which used the wrong boundaries (sum instead of start). Impact: Binary search did not narrow down the range correctly.
No Edge Case Handling (m > n):
Problem: The code didn't check if the number of students (m) was greater than the number of books (n). Impact: Returned incorrect results when allocation was impossible.
Incorrect Return Value:
Problem: The function always returned -1 due to misplaced logic. Impact: Even valid allocations failed to return the correct result.
The text was updated successfully, but these errors were encountered:
Problem: When the current student's page sum exceeded mid, the code incorrectly added the book's pages to pagesum instead of starting a new student's allocation.
Impact: Incorrect allocation logic caused feasibility checks to fail.
Binary Search Midpoint Calculation:
Problem: mid was calculated as sum + (end - sum) / 2, which used the wrong boundaries (sum instead of start).
Impact: Binary search did not narrow down the range correctly.
No Edge Case Handling (m > n):
Problem: The code didn't check if the number of students (m) was greater than the number of books (n).
Impact: Returned incorrect results when allocation was impossible.
Incorrect Return Value:
Problem: The function always returned -1 due to misplaced logic.
Impact: Even valid allocations failed to return the correct result.
The text was updated successfully, but these errors were encountered: