readings. Find the largest k such that the array contains two pieces of length k that sit **back to back** (the second starts right where the first ends) and both strictly increase.
Formally, you need an index a such that readings[a..a+k-1] and readings[a+k..a+2k-1] are both strictly increasing.
A single element counts as an increasing piece, so the answer is always at least 1. Return the largest such k.readings=[4, 6, 9, 1, 3, 8, 12, 0] → 3
The pieces [4, 6, 9] and [1, 3, 8] sit right next to each other and both strictly increase, so k = 3. No two neighbouring rising pieces of length 4 exist.
readings=[1, 2, 3, 4, 5, 6] → 3
The whole array rises, so it can be cut in half: [1, 2, 3] and [4, 5, 6].
readings=[7, 7, 7] → 1
Nothing strictly rises here, but pieces of length 1 always count as rising: [7] and [7].
readings=[4, 6, 9, 1, 3, 8, 12, 0]
3
Run checks the first 3 tests in your browser. Submit checks all 155 tests on the server, hidden ones included.