Dsa
Binary Search
Medium
Maximum Equal Slices
You are given an array of integers representing sizes of various cake slices. Your goal is to evenly distribute the slices among k people such that each person gets as close to an equal share as possible. Write a function to determine the maximum size of the smallest slice each person can receive.
Input format:
- The first line contains two integers n (number of slices) and k (number of people).
- The second line contains n space-separated integers representing the sizes of the cake slices.
Output format:
- Output the maximum size of the smallest slice each person can receive.
Example:
Input:
5 3
10 15 20 25 30
Output:
20
Key concepts
binary_searchpartitioning
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now