Ration Shop Fair Allocation Validator
Ration Shop Fair Allocation Validator
A Mumbai ration shop ensures fair grain distribution. No family receives more than L kg, and any consecutive group's total cannot exceed S kg. Given allocation array, find longest consecutive family group respecting both fairness constraints. Rule: return the longest contiguous group where EVERY allocation <= L and the group total <= S. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.
Approach
Given array of allocations, per-family limit L, and group limit S, find longest consecutive subarray respecting both constraints.
Input
Output
More Arrays problems
Browse all coding problems →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