InterviewStack.io LogoInterviewStack.io

Algorithmic Problem Solving Questions

Evaluates ability to decompose computational problems, design correct and efficient algorithms, reason about complexity, and consider edge cases and correctness. Expectation includes translating problem statements into data structures and algorithmic steps, justifying choices of approach, analyzing time and space complexity, optimizing for constraints, and producing test cases and proofs of correctness or invariants. This topic covers common algorithmic techniques such as sorting, searching, recursion, dynamic programming, greedy algorithms, graph traversal, and trade offs between readability, performance, and maintainability.

MediumTechnical
67 practiced
Implement reservoir sampling (Algorithm R) in Python to sample k elements uniformly at random from a stream of unknown length in one pass using O(k) memory. Your solution should clearly show how you update the reservoir when processing the i-th element (i > k). Explain why each stream element has equal probability of being chosen and discuss numerical stability concerns when k is large.
MediumTechnical
139 practiced
Given an array of integers, implement an algorithm in Python to return the k most frequent elements. Aim for O(n log k) time on average and O(n) extra space. Discuss alternatives like sorting by frequency, bucket sort, or using selection algorithms and when each approach is preferable based on input characteristics.
HardTechnical
67 practiced
Explain algorithmic considerations when using gradient accumulation with mixed-precision training (FP16 forward/FP32 master weights). Describe how to accumulate gradients across micro-batches to simulate a larger batch size while avoiding overflow/underflow and ensuring numeric stability and convergence. Include how loss-scaling fits into this pipeline.
HardSystem Design
80 practiced
Design an approximate nearest neighbor (ANN) service for 1M+ high-dimensional embeddings with a target p99 latency of 1–3 ms. Compare HNSW, IVF+PQ, and brute-force GPU approaches in terms of recall, memory footprint, indexing time, and update semantics. Provide memory budget calculations and a plan for SSD fallback when full index cannot fit in memory.
EasyTechnical
93 practiced
Compare Breadth-First Search (BFS) and Depth-First Search (DFS): explain algorithmic differences, typical use cases, memory/time complexity, and give concrete AI engineering examples when you would prefer one over the other (e.g., BFS for shortest path in unweighted graphs, DFS for backtracking search or cycle detection).

Unlock Full Question Bank

Get access to hundreds of Algorithmic Problem Solving interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.