readings, and you are given a threshold bar. A stretch of length k (consecutive readings) is called strong when **every** reading in it is strictly greater than bar / k. The longer the stretch, the lower the bar for its elements.
Return the length of a strong stretch, or -1 if there is none.
The input guarantees that all strong stretches, if any, share the same length, so the answer is unique.readings=[2, 7, 7, 1], bar=12 → 2
The stretch [7, 7] of length 2 works: 7 > 12 / 2 = 6. No single reading exceeds 12, and every stretch of length 3 or 4 contains a 2 or a 1, which is too small.
readings=[3, 3, 3], bar=9 → -1
Length k needs every reading above 9 / k, that is 3·k > 9. Even k = 3 gives exactly 9, not more, so the answer is -1.
readings=[5, 1, 5], bar=4 → 1
A single reading of 5 is already above 4 / 1, while any longer stretch picks up the 1.
len(readings) ≤ 10⁵readings[i] ≤ 10⁹bar ≤ 10⁹readings=[2, 7, 7, 1], bar=12
2
Run checks the first 3 tests in your browser. Submit checks all 73 tests on the server, hidden ones included.