InterviewStack.io LogoInterviewStack.io

Algorithm Design and Dynamic Programming Questions

Comprehensive topic covering algorithm design with a strong emphasis on dynamic programming across beginner to advanced levels. Candidates should be able to recognize overlapping subproblems and optimal substructure, define states and derive recurrence relations, and implement correct top down memoization or bottom up tabulation. Core problem types include Fibonacci and climbing stairs for basics, coin change and basic knapsack, intermediate patterns such as longest increasing subsequence, longest common subsequence, edit distance, and matrix chain multiplication, and advanced domains including bitmask dynamic programming, dynamic programming on trees, digit dynamic programming, game theoretic dynamic programming, and multi dimensional state spaces. Evaluation includes space and time optimization techniques such as rolling arrays, state compression, reducing dimensionality, and other algorithmic optimizations including divide and conquer optimization, monotone queue optimization, and convex hull trick when applicable. Candidates are expected to refactor brute force solutions into efficient dynamic programming implementations, reason about correctness and complexity, discuss trade offs between clarity and performance, and leverage related algorithmic building blocks such as binary search, common sorting algorithms, greedy strategies, and appropriate data structures to improve solutions.

EasyTechnical
0 practiced
Compare the time complexity and call counts of naive recursive Fibonacci versus memoized top-down DP and bottom-up DP. Provide the exact recurrence for number of calls in naive recursion and explain the practical implications (CPU-, memory-usage) when such recurrences appear in production monitoring code.
HardTechnical
0 practiced
Design an online algorithm that approximates the optimal DP solution for allocating burst tokens (rate-limiting budget) across services when future requests are unknown and memory is limited. Propose heuristics or learning-based controllers (e.g., multiplicative weights, doubling), provide regret bounds if applicable, and describe how you'd validate in simulated production traffic.
HardTechnical
0 practiced
Explain impartial combinatorial games and the Sprague-Grundy theorem. Given a game where each component is an integer health and a move reduces one component's health by a chosen positive amount (with per-component rules), describe how to compute Grundy numbers using DP/memoization for up to n <= 20 components, detect winning positions, and discuss applicability to adversarial rollback planning in SRE.
HardTechnical
0 practiced
Explain Convex Hull Trick (CHT) and how to apply it to optimize DP of the form dp[i] = min_j (m_j * x_i + b_j). Describe offline sorted-x approach (maintain lower envelope with pointer) and online approaches (Li Chao tree or dynamic hull). Apply to an SRE cost model where cost of adding capacity is linear with varying slopes and queries arrive online. Provide pseudo-code and complexity comparisons.
MediumTechnical
0 practiced
Given an R x C grid (R,C <= 2000) where some cells are blocked, implement Python function count_paths(grid) that returns number of ways to go from top-left to bottom-right moving only right or down, modulo 1e9+7. Discuss DP with rolling arrays for memory efficiency and optimizations for sparse obstacles that SREs might encounter in large-scale topology maps.

Unlock Full Question Bank

Get access to hundreds of Algorithm Design and Dynamic Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.