Tap here to switch tabs
Problem
Submissions

Problem: Minimum Rounds to Complete All Tasks

Minimum Rounds to Complete All Tasks groups an array of tasks by difficulty and asks for the fewest rounds, with two or three matching tasks per round, or negative one if impossible.

Statement

You are given an integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 22 or 33 tasks of the same difficulty level.

Return the minimum number of rounds required to complete all tasks, or −1-1 if it is impossible to complete all the tasks.

Constraints:

  • 1≤1 \leq tasks.length ≤105\leq 10^5

  • 1≤1 \leq tasks[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Rounds to Complete All Tasks

Minimum Rounds to Complete All Tasks groups an array of tasks by difficulty and asks for the fewest rounds, with two or three matching tasks per round, or negative one if impossible.

Statement

You are given an integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 22 or 33 tasks of the same difficulty level.

Return the minimum number of rounds required to complete all tasks, or −1-1 if it is impossible to complete all the tasks.

Constraints:

  • 1≤1 \leq tasks.length ≤105\leq 10^5

  • 1≤1 \leq tasks[i] ≤109\leq 10^9