Place Containerized Workloads on Fixed-Capacity Worker Nodes

Last updated: November 29, 2026

Quick Overview

Given CPU requests for a set of workloads and the capacities of several OpenShift worker nodes, return an assignment of every workload to a node without exceeding any capacity, or None if impossible.

IBM
Coding & Algorithms
Software Engineer
IBM
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given CPU requests for a set of workloads and the capacities of several OpenShift worker nodes, return an assignment of every workload to a node without exceeding any capacity, or None if impossible.

Scheduling pods onto nodes is bin packing, and IBM interviewers on Red Hat OpenShift and IBM Cloud Kubernetes Service teams use small exact versions to test backtracking with pruning. They check that you order the search well, prune symmetric branches, and can explain why the production scheduler uses heuristics instead.

What the Interviewer Expects
  • Frame the problem as exact bin packing via backtracking
  • Sort workloads largest first to fail fast
  • Skip nodes with identical remaining capacity to prune symmetry
  • Return the actual assignment, not only feasibility
  • Explain NP-hardness and when heuristics like first-fit decreasing are used
Key Topics to Cover
backtracking
bin packing
pruning
NP-hard
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
  • How would you minimize the number of nodes used instead?
  • How would you add anti-affinity, so two replicas cannot share a node?
  • What does the real Kubernetes scheduler do differently?
  • How would memoization on remaining capacities help?
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: requests, a list of positive integers (millicores), and caps, the capacities of nodes. Output: a list assign where assign[i] is the node index for workload i, or None. Sizes are sma...

High-Level Design

Process workloads from largest to smallest, since big items have the fewest valid placements and cause early failure. Keep remaining capacity per node. For each workload, try each node that can fit ...


Submit Your Answer
Markdown supported

Related Questions