⌘K
Flycodx

IPL Franchise Budget Allocation

IPL Franchise Budget Allocation

MediumArrays100% accepted

Priya, an IPL franchise manager, has a budget for player auctions. She must purchase players in order without skipping, selecting from available players. Find the maximum number of consecutive players she can buy within her budget constraint. Rule: return the maximum length of a CONTIGUOUS run of players whose total price fits within the budget. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.

Approach

Given an array of player base prices and a budget limit, find the maximum count of consecutive players (from any starting position) that can be purchased.

Input

prices=[8,12,15,7,10,5,6] budget=50

Output

5
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3