sales[i] is the number of units sold on day i. A day is strong when sales[i] > target, otherwise weak. A streak of consecutive days is called strong when it contains strictly more strong days than weak days. Return the length of the longest strong streak, or 0 if there is none.
Examples
Input: sales = [12, 5, 9, 14, 6, 3], target = 8
Output: 5
Explanation: days 0..4 have 3 strong days (12, 9, 14) and 2 weak days; adding day 5 would tie 3-3.
Input: sales = [1, 2], target = 5
Output: 0
Input: sales = [9, 1, 1], target = 8
Output: 1
Constraints
1 <= len(sales) <= 10**50 <= sales[i] <= 10**6,0 <= target <= 10**6- Target complexity: O(n) time. Examining every streak is too slow for the largest tests.
Goals
- Encode a majority condition as a +1/-1 prefix sum
- Use the step-by-one property of the prefix to find the earliest smaller value