Question bank › Binary Search
Dsa Binary Search Medium

Minimum Time to Complete Tasks

You are given an array of integers where each integer represents the amount of time needed to complete a task. You can work on tasks in parallel with a limit on the total time available. Your task is to determine the minimum time required to complete all tasks by grouping them into batches that do not exceed the available time limit. Input Format: - The first line contains an integer n (1 ≤ n ≤ 1000), the number of tasks. - The second line contains n space-separated integers representing the time required for each task. - The third line contains an integer t (1 ≤ t ≤ 10000), the available total time. Output Format: - A single integer indicating the minimum number of batches needed to complete all tasks within the time limit. Example: Input: 5 2 3 4 5 6 8 Output: 3

Key concepts

binary_searchsortinggreedy

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.