Complete the code to initialize the binary search boundaries.
let mut low = 0; let mut high = [1];
We set high to the length of the array as the upper boundary for binary search.
Complete the code to calculate the middle index safely.
let mid = low + ([1] - low) / 2;
We calculate mid as low + (high - low) / 2 to avoid overflow.
Fix the error in the condition to check feasibility in binary search.
if [1](mid) { high = mid; } else { low = mid + 1; }
The function is_feasible checks if mid satisfies the condition.
Fill both blanks to update the search boundaries correctly.
if is_feasible(mid) { [1] = mid; } else { [2] = mid + 1; }
When mid is feasible, we move high to mid; otherwise, move low to mid + 1.
Fill all three blanks to return the final answer after binary search.
while low < high { let mid = low + (high - low) / 2; if is_feasible(mid) { [1] = mid; } else { [2] = mid + 1; } } let answer = [3];
Inside the loop, high is updated when feasible, low otherwise. The final answer is low.
