Rack heights stand in a row at unit spacing. Pick two racks; the storage between them is min(h[i], h[j]) × (j - i). Return the maximum storage.
Signature
maxStorage(heights: int[]) → intExample 1
heights = [1,8,6,2,5,4,8,3,7]
output = 49
racks 1 and 8: min(8,7) × 7 = 49
Example 2
heights = [1,1]
output = 1
Constraints
2 ≤ n ≤ 10^50 ≤ heights[i] ≤ 10^4
⌘/Ctrl + Enter runs examples
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).