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.

EasyTechnical
82 practiced
Given an integer array nums and a sliding window size k, implement a function in Python that returns an array of the maximum values in each sliding window of size k. Requirement: O(n) time total and O(k) space. Example: nums = [1,3,-1,-3,5,3,6,7], k = 3 -> result = [3,3,5,5,6,7].
EasyTechnical
93 practiced
Design and implement a class in Python that maintains the median of an online stream of integers. Provide methods add(num) to add a number and median() to return the current median. Requirement: each add should be O(log n) time and overall space O(n). Explain how two heaps are used and handle even/odd counts.
HardTechnical
73 practiced
Prove Raft's election safety property: at most one leader can be elected in a given term. Outline the invariants required and explain how term numbers and voting restrictions enforce safety. Then propose a change to reduce election churn during network partitions and discuss why your change preserves safety.
MediumTechnical
64 practiced
Describe and implement the algorithm for consistent hashing to shard keys across nodes. Explain how to use virtual nodes to improve balance, and provide pseudocode for key-to-node mapping, node join, and node leave. Analyze the expected fraction of keys that must move on membership changes.
EasyTechnical
91 practiced
You need to uniformly sample approximately 1% of a very high volume log stream for long-term archival, but you cannot store the full stream. Describe and implement reservoir sampling for sample size k in Python, and prove why the algorithm maintains a uniform sample.

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.