Search for a command to run...
Bob is betting on horses. You are given N (number of horses) and K (Bob's budget). An array of N integers represents the price of betting on each horse in sequence.
Find the maximum length of a continuous sequence of horses Bob can bet on such that the total cost is strictly less than K.
If multiple such sequences exist, return the maximum length found.
Input: N = 10 K = 100
Prices: 30 40 50 20 20 10 90 10 10 10
Output: 3
Explanation: Possible sequences with sum < 100 are:
[50, 20, 20] → sum = 90
[10, 10, 10] → sum = 30
Both sequences have length = 3.
No sequence of length 4 has a total sum less than 100.
Example 1
10, 100, 30, 40, 50, 20, 20, 10, 90, 10, 10, 103Example 2
5, 50, 10, 10, 10, 10, 10410, 100, 30, 40, 50, 20, 20, 10, 90, 10, 10, 10
3