FastPrepMinimum Rounds to Complete All Tasks
Problems/Minimum Rounds to Complete All Tasks

Minimum Rounds to Complete All Tasks

Infosys logoInfosys● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Infosys full-time offline assessment. The first of four coding questions was the well-known Minimum Rounds to Complete All Tasks problem. The candidate named a greedy count with a hash map as the approach. The post gives only a total test score for the four questions, not a result for this one.

Only the problem name was shared, so the rules and limits here are the usual ones for that problem.

Our version is about 95% the same as the reported question.

You are given an integer array tasks. tasks[i] is the difficulty level of task i.

In one round you finish either 2 or 3 tasks, and all tasks finished in that round must have the same difficulty level.

Return the smallest number of rounds needed to finish every task. If it is impossible, return -1.

Function

minimumRounds(tasks: int[]) → int

Examples

Example 1

tasks = [5,5,5,7,7,9,9,9,9]return = 4

Level 5 has 3 tasks: one round of 3. Level 7 has 2 tasks: one round of 2. Level 9 has 4 tasks: two rounds of 2. That is 1 + 1 + 2 = 4 rounds.

Example 2

tasks = [3,8,3]return = -1

There is only one task of level 8. A round needs at least 2 tasks of the same level, so this task can never be finished.

Example 3

tasks = [6,6,6,6,6,6,6]return = 3

There are 7 tasks of level 6. Use one round of 3 and two rounds of 2: 3 + 2 + 2 = 7. Two rounds can finish at most 6 tasks, so 3 rounds is the best.

Constraints

  • 1 <= tasks.length <= 10^5
  • 1 <= tasks[i] <= 10^9

More Infosys Online Assessment questions

  • Lowest Common Ancestor with a Changing RootOA · Seen Nov 2026
  • Minimum Leaf Path Sum over All RootsOA · Seen Nov 2026
  • Split Array to Minimize the Largest SumOA · Seen Nov 2026
  • Cherry PickupOA · Seen Nov 2026
  • Lexicographically Smallest Grid Path with One Letter ChangeOA · Seen Nov 2026
  • Minimum Cost to Supply Water with Wells and PipesOA · Seen Nov 2026
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3OA · Seen Nov 2026
  • Count Equal-Distinct Character PartitionsOA · Seen Oct 2026
  • Maximum Alternating-Index Packet ValueOA · Seen Oct 2026
  • Usable Water with Contaminated PillarsOA · Seen Oct 2026

Similar questions at other companies

  • Maximum MEXAtlassian · OAAtlassian interview questions
  • Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Task Scheduler with CooldownGoDaddy · OA
  • Minimize Adjacent Squared-Difference Cost with One InsertionMcKinsey & Company · OAMcKinsey & Company interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Get Triplet CountIBM · OAIBM interview questions
  • Minimum Values with Even Powers of TwoVisa · OAVisa interview questions
  • Resource AllocationMaven Securities · OAMaven Securities interview questions
All Infosys interview questionsSee Infosys hiring insights
Saved
class Solution {
    public int minimumRounds(int[] tasks) {
        // Write your code here.
    }
}
Checking account…