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
77 practiced
Implement an algorithm in C++ to compute the length of the Longest Increasing Subsequence (LIS) in O(n log n) time and O(n) space using the patience-sorting method. Explain the tails array idea and provide example input [10,9,2,5,3,7,101,18] -> result 4. Also discuss how to reconstruct the actual subsequence.
EasyTechnical
97 practiced
Compare DFS and BFS: discuss traversal order, memory usage, path-finding properties, and use-case suitability. Provide examples where BFS is the correct choice (shortest path in unweighted graph) and where DFS is better (space-limited deep search). Explain iterative deepening DFS and when to use it.
HardTechnical
151 practiced
Explain and implement suffix array construction in O(n log n) time using the doubling algorithm (sort by 2^k prefixes) and then construct the LCP array with Kasai's algorithm in O(n). Provide either Python or C++ code structure, discuss memory/time trade-offs, and applications in NLP and bioinformatics.
HardTechnical
74 practiced
Explain the Optimal Binary Search Tree (OBST) dynamic programming solution: given sorted keys and access frequencies, construct a BST minimizing expected search cost. Provide the DP recurrence, an O(n^3) implementation outline, and explain Knuth optimization that reduces it to O(n^2) under quadrangle inequality. Discuss practicality and heuristics for very large n.
MediumTechnical
75 practiced
Implement a simplified regular expression matcher in Python that supports '.' (matches any single character) and '*' (matches zero or more of the preceding element) without using built-in regex libraries. Signature: `def is_match(s: str, p: str) -> bool`. Provide the O(mn) dynamic programming solution and explain the DP state transitions.

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.