Asked inSamsung Research,R&D Intern

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
Select
Add answer anonymously...
Samsung Research R&D Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits