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.

MediumTechnical
114 practiced
Explain how HyperLogLog estimates distinct items in a stream: include register structure, the role of hashing, and how multiple registers combine to yield an estimate. Given a 100KB memory budget and expected cardinality up to 1e9, propose HLL parameters (p) and estimate the expected relative error. Also explain how to merge sketches from shards.
HardSystem Design
86 practiced
You operate a geographically replicated key-value store with limited inter-region bandwidth but require linearizable writes. Propose protocol optimizations to reduce message count and bandwidth: e.g., leader leases for local reads, batching Raft/Appends, digest-only snapshots, or client-side leases. Analyze impacts on latency, freshness, and failure scenarios (leader loss, partition).
EasyTechnical
93 practiced
On some embedded platforms, division is slow or unavailable. Describe practical methods to compute integer division and modulo without using / or %: e.g., shift-and-subtract (long division), multiplication by reciprocal using fixed-point precomputed multipliers, and table-lookup for small divisors. For each method, state performance, precision trade-offs, and appropriate use cases.
MediumSystem Design
94 practiced
Design a backend system to handle 100,000 requests/sec with p95 latency <= 50ms. Servers are CPU-limited (small VMs). Describe architecture choices (stateless services, sharding), caching layers (CDN, edge cache, in-memory), request batching, offloading, and techniques to reduce CPU per request (precomputation, protocol optimization). Explain how to detect and gracefully degrade under overload.
EasyTechnical
95 practiced
Explain the time-space trade-off between memoization and recomputation. Use two concrete examples: (a) naive Fibonacci recursive computation; (b) 0/1 knapsack dynamic programming. For each example explain when memoization is beneficial and when bottom-up or recomputation is preferable given a tight memory budget. Provide complexity (time and space) for both approaches.

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.