Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Minimize Batch Processing Time

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Minimize Batch Processing Time. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

At Stripe, an engineering team tracks repeated workload sizes in a batch job and wants to reduce processing overhead. Given an integer array tasks, return the minimum number of operations needed to remove all tasks, where one operation can remove either 2 equal values or 3 equal values.

If it is impossible to remove all tasks under these rules, return -1.

Formal Specification

  • Input: tasks — a list of integers
  • Output: An integer representing the minimum number of operations required to remove all elements, or -1 if no valid sequence exists

Constraints

  • 1 <= len(tasks) <= 10^5
  • 1 <= tasks[i] <= 10^9
  • Each operation removes exactly 2 or 3 equal values

Function Signature

def min_operations(tasks):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output