1) or not (0). Their logs are the arrays first and second of equal length.
Find the longest window of consecutive minutes [i, j] (i ≤ j) in which both sensors fired the same number of times, meaning the sum of first[i..j] equals the sum of second[i..j]. Return the length of that window, j - i + 1, or 0 if no such window exists.first=[1, 0, 1, 1, 0], second=[0, 1, 1, 0, 0] → 4
Window 0–3: first has 1 + 0 + 1 + 1 = 3 ones and second has 0 + 1 + 1 + 0 = 2, so it does not work. Window 1–4 gives 0 + 1 + 1 + 0 = 2 and 1 + 1 + 0 + 0 = 2, which match, length 4. The whole window 0–4 gives 3 against 2.
first=[1, 1], second=[0, 0] → 0
Every window has more ones in first than in second, so the answer is 0.
first=[0, 1, 0], second=[1, 0, 1] → 2
first=[1, 0, 1, 1, 0], second=[0, 1, 1, 0, 0]
4
Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.