InterviewStack.io LogoInterviewStack.io

Algorithm Design and Analysis Questions

Covers algorithmic problem solving and analysis fundamentals required in technical interviews. Topics include common data structures, sorting and searching, recursion and divide and conquer, dynamic programming, greedy strategies, backtracking, graph algorithms such as breadth first search and depth first search, shortest path and topological sort, string algorithms, and techniques for deriving correct and efficient solutions. Candidates should demonstrate ability to reason about correctness, derive time and space complexity bounds using Big O notation, and discuss scalability and optimization trade offs for large inputs.

MediumTechnical
88 practiced
Implement a function in Python that, given an integer array nums and window size k, returns an array of maximum values for each sliding window in O(n) time and O(k) space. Example: nums=[1,3,-1,-3,5,3,6,7], k=3 -> [3,3,5,5,6,7]. Explain why using a deque yields linear time and discuss handling when input is a stream.
HardTechnical
90 practiced
Given N ≤ 40 integers (possibly negative), design and implement a meet-in-the-middle algorithm in Python to find a subset whose sum is closest to a target T faster than O(2^N). Explain splitting the array, enumerating half-sums, sorting, binary searching complements, and analyze time and memory complexity.
EasyTechnical
92 practiced
Explain formal definitions and differences between Big O, Big Theta, and Big Omega notation. Give concrete examples and derive tight asymptotic bounds for f(n)=3n^2+10n log n+100. Describe worst-case, average-case, and amortized complexity and explain when each is important in production data pipelines and model training jobs.
MediumTechnical
78 practiced
Implement Union-Find (disjoint set union) with path compression and union by rank in Python. Then use it to implement Kruskal's algorithm to compute the Minimum Spanning Tree (MST) of an undirected weighted graph. Discuss time complexity of union-find operations and overall Kruskal runtime including sorting edges.
MediumTechnical
73 practiced
Design a single-pass algorithm to compute rolling mean and variance over the last W items of a real-time numeric stream (W can be up to 1M) and flag anomalies when values exceed mean +/- 3*stddev. Constraints: limited memory, single pass, numerical stability. Explain Welford's algorithm for streaming variance and how to remove expired items from a fixed window.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.