InterviewStack.io LogoInterviewStack.io

Intermediate Algorithm Problem Solving Questions

Practical skills for solving medium difficulty algorithmic problems. Topics include two pointer techniques, sliding window, variations of binary search, medium level dynamic programming concepts such as recursion with memoization, breadth first search and depth first search on graphs and trees, basic graph representations, heaps and priority queues, and common string algorithms. Emphasis is on recognizing problem patterns, constructing correct brute force solutions and then applying optimizations, analyzing trade offs between time and space, and practicing systematic approaches to reach optimal or near optimal solutions.

MediumTechnical
30 practiced
Given k sorted linked lists, merge them into one sorted linked list. Provide a Python implementation using a heap (priority queue) achieving O(N log k) time where N is total nodes. Use tuples like (value, unique_id, node) to avoid comparison-of-node errors. Example: [[1,4,5],[1,3,4],[2,6]] -> [1,1,2,3,4,4,5,6].
EasyTechnical
19 practiced
Given an unsorted integer array and integer k, return the k smallest elements in any order. Implement a Python function using a heap (expected O(n log k) time). For small k, maintain a max-heap of size k. Example: arr=[7,10,4,3,20,15], k=3 -> [3,4,7].
MediumTechnical
35 practiced
Implement a Python function to return the length of the longest substring without repeating characters. Use an efficient sliding-window with a hash map of last-seen indices to achieve O(n) time. Example: s='pwwkew' -> 3.
HardTechnical
20 practiced
For an ML serving system with 512-dimensional embeddings, 1M vectors and a 200ms latency requirement, compare approximate nearest neighbor (ANN) approaches: brute-force, KD-tree, locality-sensitive hashing (LSH), product quantization (PQ), and graph-based methods like HNSW. Discuss accuracy vs latency vs memory trade-offs, indexing time, and update costs, and explain how you'd choose between them.
HardTechnical
19 practiced
Scenario: You need to run BFS from a source on a graph that is too large to fit in memory (edges sharded across disks or machines). Describe algorithms and engineering approaches to perform BFS: external-memory BFS, frontier-based processing, compressing adjacency formats (CSR), batching, and use of distributed frameworks (Pregel, GraphX). Explain how to minimize IO and network shuffle.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.