Complete the code to initialize the low boundary for binary search.
int low = [1];We start binary search from 0 as the lowest possible answer.
Complete the code to calculate the mid value safely to avoid overflow.
int mid = low + (high - low) [1] 2;
We use division by 2 to find the middle point between low and high.
Fix the error in the condition to update the high boundary.
if (canAchieve(mid)) { high = [1]; } else { low = mid + 1; }
If mid is achievable, we move high to mid to search for a smaller answer.
Fill both blanks to complete the binary search loop condition and update low boundary.
while (low [1] high) { int mid = low + (high - low) / 2; if (canAchieve(mid)) { high = mid; } else { low = mid [2] 1; } }
The loop runs while low is less than high. When mid is not achievable, low moves to mid + 1.
Fill all three blanks to create a map of word lengths filtered by length greater than 3.
Map<String, Integer> lengths = words.stream()
.filter(word -> word.length() [1] 3)
.collect(Collectors.toMap(
word -> word.[2](),
word -> word.length() [3] 1
));We filter words with length greater than 3, map keys to uppercase words, and values to length plus 1.
