Hardware interview practice
Verify a channel-capacity optimizer
Write an independent oracle for a software-programmed static random-access memory (SRAM) optimizer. For endpoints left < right, area is min(height[left], height[right]) times (right - left); return the maximum and the first maximizing pair visited by the specified two-pointer walk.
Reviewed example
Work through one case
Input
programmed heights = [1, 8, 6, 2, 5, 4, 8, 3, 7]Expected output
maximum_area=49; left_index=1; right_index=8The limiting height is 7 across a width of 7; the two-pointer visit order reaches this first maximizing pair.
What to cover
Requirements
- Compute the true maximum across every endpoint pair, then emulate a walk beginning at both ends: advance left when the left height is less than or equal to the right height, otherwise decrement right.
- Return the first pair visited by that walk whose area equals the mathematical maximum.
- Treat counts outside 2 through 32 as bad_count with zero area and indices.
- Use widened unsigned arithmetic for the product and make the equal-height branch explicit.
- Treat accepted-write Register Abstraction Layer (RAL) prediction, start priority, response hold, reset retention, and stale-response checks as follow-up environment design.
