InterviewStack.io LogoInterviewStack.io

Fundamental Algorithms and Techniques Questions

Covers core algorithmic concepts and problem solving patterns commonly assessed in technical interviews. Topics include searching algorithms such as binary search; sorting algorithms such as merge sort and quick sort; graph traversal methods such as breadth first search and depth first search; recursion and divide and conquer techniques; greedy heuristics; and dynamic programming including memoization and tabulation. Also includes implementation patterns such as two pointers, sliding window, prefix sums, and divide and conquer composition, as well as practical considerations like in place versus out of place implementations, stability for sorting, recursion stack and memory usage, and amortized analysis. Candidates should be able to implement these algorithms correctly, explain correctness and trade offs, analyze time and space complexity using Big O notation for best case average case and worst case, select appropriate approaches given input constraints, combine patterns to solve composite problems, and optimize or refactor solutions while handling edge cases.

MediumTechnical
73 practiced
Implement an O(n log n) algorithm in Python to compute the length of the Longest Increasing Subsequence (LIS) using the patience-sorting technique. Explain how the 'tails' array and binary search work, how to reconstruct one LIS (store predecessors), and how this could be useful for identifying monotonic trends in hyperparameter sequences.
MediumTechnical
83 practiced
Implement Disjoint Set Union (Union-Find) in Python with path compression and union by rank/size. Provide functions find(x), union(x,y), and connected(x,y). Explain amortized time per operation (inverse Ackermann), and show an example use in finding connected components in an undirected graph, such as grouping similar image pixels.
HardTechnical
73 practiced
Explain quicksort's worst-case behavior and describe the median-of-medians pivot selection algorithm that guarantees linear-time selection and prevents worst-case degeneracy. Discuss implementation trade-offs: why median-of-medians guarantees O(n log n) sorting but has practical overhead compared to randomized pivoting, and when you'd choose one over the other.
MediumTechnical
90 practiced
Implement an efficient algorithm in Python to count inversion pairs in an array (number of pairs i<j with a[i]>a[j]) using divide-and-conquer (merge sort) in O(n log n) time. Explain how counting inversions relates to Kendall tau distance for ranking comparisons in ML and how you'd handle large inversion counts (big integers or modulo arithmetic).
HardTechnical
66 practiced
Given an integer array nums (which may contain negative numbers) and an integer k, find the maximum subarray sum no larger than k. Explain why sliding-window fails when negatives are allowed, and implement an O(n log n) solution in Python using prefix sums and a balanced BST or sorted list to find the required preceding prefix sums. Discuss use cases such as maximizing embedding similarity under budget constraints.

Unlock Full Question Bank

Get access to hundreds of Fundamental Algorithms and Techniques interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.