readings. An analyst wants to know whether the value climbed steadily for two periods in a row.
Decide whether the array contains two **adjacent** windows of length length that are both strictly increasing. Adjacent means the second window starts right where the first one ends: if the first covers indices a … a + length - 1, the second covers a + length … a + 2·length - 1.
Nothing is required at the seam: the last value of the first window may be larger than the first value of the second.
Return true if such a pair exists and false otherwise.readings=[4, 6, 9, 1, 3, 8, 2], length=3 → True
[4, 6, 9] is strictly rising and right after it comes [1, 3, 8], which rises too. They sit back to back.
readings=[1, 2, 3, 3, 4, 5], length=3 → True
The only back-to-back pair of length-3 windows is [1, 2, 3] and [3, 4, 5]. Both rise, so the answer is true. With length=4 it would be false.
readings=[5, 5, 5, 5], length=1 → True
readings=[4, 6, 9, 1, 3, 8, 2], length=3
True
Run checks the first 3 tests in your browser. Submit checks all 125 tests on the server, hidden ones included.