Furthest Episode Meeting a Completion Threshold
Problem statement
viewerCounts[i] is the recorded viewer count for episode i + 1. The final entry is used only as the number of people who finished the complete series; it is not a candidate episode.
Let threshold = ceil(70% * viewerCounts[n - 1]). Return the largest 1-based index among episodes 1..n-1 whose count is at least threshold. Return -1 if no earlier episode qualifies.
Function
furthestEpisodeAtCompletionThreshold(viewerCounts: int[]) → intExamples
Example 1
viewerCounts = [40,20,6,5,4,6,7,4,3,10]return = 7The final count is 10, so the threshold is 7. Episode 7 is the largest earlier index whose count reaches 7.
Constraints
2 <= viewerCounts.length <= 100000.0 <= viewerCounts[i] <= 10^9.- The final count is positive.