Chocolates Distribution Problem Statement
Dr. Stephen wants to distribute chocolates fairly among K children. He has N boxes of chocolates arranged in a row, each containing a different number of chocolates. The goal is to distribute the maximum number of chocolates equally among the K children, but only by selecting consecutive boxes of chocolates.
Task:
Given N boxes of chocolates, determine the maximum number of chocolates each child can get when the chocolates must be chosen from consecutive boxes.
Example:
Input:
Boxes: [3, 2, 2, 5, 4, 1], Students: 5
Output:
2
Explanation:
Without the consecutive box constraint, each student could potentially get 3 chocolates. However, considering only consecutive boxes, the optimal selection is boxes [4, 6], where the chocolates sum to 10, allowing each student to receive 2 chocolates.
Constraints:
1 <= T <= 10
1 <= N <= 10^5
1 <= K <= 10^5
0 <= boxes[i] <= 10^5
- Time Limit: 1 sec
Be the first one to answer
Add answer anonymously...
>
Samsung Research R&D Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

