The Pour Water Between Buckets to Make Water Levels Equal problem gives you buckets with different water amounts and a loss percentage per pour. Find the maximum equal water level achievable. This coding problem uses binary search on the answer (the target level) with a feasibility check. The array and binary search interview pattern is demonstrated.
Deutsche Bank asks this to test binary search on the answer with a custom feasibility check. The monotonic property: if level L is achievable, any level L' < L is also achievable. Binary search on the decimal level value and verify if total gained water (from pouring excess buckets) can fill all below-L buckets given the loss.
Binary search on target level. For a given level L: water gained from buckets above L = sum(bucket - L for bucket > L) multiplied by (100 - loss) / 100. Water needed to fill below-L buckets = sum(L - bucket for bucket < L). If gained >= needed, L is feasible. Binary search for the maximum feasible L with precision (e.g., 1e-5 iterations or 100 iterations of floating-point binary search).
buckets=[1,2,7], loss=80. L=3: gain from 7=(7-3)*0.2=0.8. Need for 1,2: (3-1)+(3-2)=3. 0.8<3, not feasible. L=2: gain=(7-2)*0.2=1. Need=(2-1)=1. 1>=1 ✓. L=2 is achievable. Answer ≈ 2.00000.
Floating-point binary search problems iterate ~100 times with mid = (lo + hi) / 2 until convergence. The feasibility check defines the monotone condition. Practice floating-point binary search on: "minimum time," "maximum efficiency," "optimal allocation" problems where the answer is a real number. The convergence criterion (100 iterations or error < 1e-6) is standard.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Koko Eating Bananas | Medium | Solve | |
| Adjacent Increasing Subarrays Detection II | Medium | Solve | |
| Capacity To Ship Packages Within D Days | Medium | Solve | |
| Cutting Ribbons | Medium | Solve | |
| Earliest Second to Mark Indices I | Medium | Solve |