Inspired by Vaibhav Sooryavanshi's record-breaking 204 off 53 balls, you are given a ball-by-ball record of an innings as an integer array runs, where runs[i] represents the number of runs scored on the i-th ball faced.
Given an integer target (default 50), return the minimum number of consecutive balls required to score at least target runs at any point in the innings.
If it is impossible to reach target runs across the entire innings, return -1.
Example 1 — Explosive Powerplay
Input: runs = [0, 4, 6, 6, 4, 1, 6, 6, 6, 4], target = 20
Output: 4
Explanation: Both [4, 6, 6, 4] (20 runs) and [6, 6, 6, 4] (22 runs) reach at least 20 runs in just 4 consecutive balls.
Example 2 — Exact Boundary
Input: runs = [4, 4, 6, 6, 4, 6, 6, 6, 4, 4], target = 50
Output: 10
Explanation: The entire 10-ball innings sums to exactly 50 runs.
Example 3 — Impossible Target
Input: runs = [0, 1, 2, 4, 0, 1, 4], target = 50
Output: -1
Explanation: Total runs scored in the innings is 12, which is less than 50.
Constraints
1 <= len(runs) <= 10^50 <= runs[i] <= 7(0–6 runs, or 7 with overthrows)1 <= target <= 10^6- Target Complexity:
O(N)time,O(1)space.
Progressive Hints
Preparing Python...
Tip: Switch to desktop for the best coding experience — problem descriptions and explainer videos work great on mobile.
Loading code editor...
Test Cases• 4 sample / 6 total cases
Ctrl+Enter Run · Ctrl+Shift+Enter SubmitCase 1: Vaibhav Sooryavanshi 204 (53) — IND A vs UAEESPNcricinfo Scorecard · IND A vs UAE (2026)
Not run yetInput: runs = [0, 0, 6, 6, 6, 1, 4, 0, 1, 6, 6, 0, 6, 0, 6, 6, 6, 4, 6, 6, 0, 0, 6, 6, 1, 6, 4, 4, 6, 6, 4, 2, 1, 6, 1, 6, 4, 6, 0, 6, 6, 0, 6, 1, 6, 6, 6, 6, 4, 0, 6, 6, 0], target = 50
Expected: 11