InterviewStack.io LogoInterviewStack.io

Algorithm Design Under Constraints Questions

Solving problems when strict constraints are present such as time limits, space limits, forbidden operations, or resource restrictions. Candidates should demonstrate understanding of trade offs, selecting appropriate algorithms or heuristics given constraints, reasoning about complexity and feasibility, and communicating why one approach is preferable under the given limitations.

EasyTechnical
88 practiced
You have a continuous stream of billions of user events per day but budget allows keeping only 1% of raw events. Design a summarization pipeline that supports anomaly detection and heavy-hitter identification under the 1% storage constraint. Discuss algorithms (count-min sketch, bloom filters, reservoir sampling, t-digest), error characteristics, and how you'd evaluate the system for precision/recall under memory limits.
MediumSystem Design
67 practiced
Design a training pipeline when network bandwidth between datacenters is limited (e.g., 10 Gbps) and cross-data-center synchronization must be minimized. Data is partitioned by region but you need a global model. Discuss architecture choices (federated learning, parameter server with periodic aggregation, asynchronous SGD, gradient compression/sparsification), trade-offs in accuracy and freshness, and a deployment plan to meet a fixed cost budget.
HardTechnical
78 practiced
You're training a recommendation model with a categorical feature space of 100M unique keys and embedding size 128, which cannot fit in GPU memory. Design and provide pseudo-code for an efficient embedding lookup and training strategy that uses CPU memory with SSD-backed cache and hot-key caching on GPU, and uses sampled softmax or negative sampling during training to limit memory and compute pressure. Discuss trade-offs and consistency issues.
MediumTechnical
70 practiced
You are forbidden from using any external pre-trained models or weights and have limited compute and labeled data. Propose a practical training strategy to reach acceptable performance: consider architecture selection, strong data augmentation, synthetic data generation, self-supervised pretraining on unlabeled in-domain data, active learning, and validation methodology given compute limits.
EasyTechnical
91 practiced
You must deploy an image classification model to an edge device that has 128MB total RAM, no GPU, and an average inference latency requirement of 50ms. You are not allowed to call cloud inference. Describe an end-to-end plan to fit and ship a model under these constraints: model selection, compression techniques, runtime choices (e.g., TFLite/ONNX), testing on-device, and rollout plan for updates.

Unlock Full Question Bank

Get access to hundreds of Algorithm Design Under Constraints interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.