Minimum Time Slots to Run Transcode Tasks With Per-Codec Cooldown

Last updated: November 29, 2026

Quick Overview

A single GPU worker runs one transcode task per time slot, and two tasks of the same codec must be at least n slots apart because of encoder warm-down; return the minimum slots needed to run all tasks, idling when necessary.

ByteDance
Coding & Algorithms
Software Engineer
ByteDance
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


A single GPU worker runs one transcode task per time slot, and two tasks of the same codec must be at least n slots apart because of encoder warm-down; return the minimum slots needed to run all tasks, idling when necessary.

ByteDance's video infrastructure batches transcodes for H.264, H.265 and AV1 on shared hardware, which makes this a natural framing for a scheduling question in their technical screens. The interviewer checks whether you find the counting formula and can justify it, not only simulate with a heap.

What the Interviewer Expects
  • Recognize the most frequent codec dictates the frame structure
  • Derive (max_count - 1) * (n + 1) + number_of_codecs_tied_for_max
  • Take the max with the total task count when idles are not needed
  • Offer a heap simulation that also produces the schedule
  • State O(T) time
Key Topics to Cover
greedy
counting
heaps
scheduling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Return an actual valid schedule, not just its length.
  • Tasks have different durations: is the formula still valid?
  • With m identical workers, how does the bound change?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: a list of task codecs and cooldown n >= 0. Each slot runs one task or idles. Two equal codecs must have at least n slots between them. Output: the minimum number of slots....

High-Level Design

Let the most frequent codec appear top times. It splits the schedule into top - 1 full frames of length n + 1, followed by a final partial frame. Codecs tied at top all appear in that last frame. Othe...


Submit Your Answer
Markdown supported