DSA & Coding Interview Questions
Complexity, arrays and strings, hashing, linked lists, stacks, trees, graphs, sorting, recursion, dynamic programming and greedy — the reasoning behind the code, not just the solutions.
Showing 1–20 of 100
#1What does Big-O notation actually measure, and what does it deliberately ignore?
#2What is the difference between Big-O, Big-Omega, and Big-Theta?
#3Explain amortised complexity using ArrayList as an example.
#4How do you calculate the space complexity of a recursive function?
#5Why is O(log n) so much better than O(n), concretely?
#6What is the difference between an array and a linked list, and when would you pick each?
#7How would you detect that your algorithm has accidental O(n²) behaviour?
#8What is the time complexity of building a heap from an array, and why is it not O(n log n)?
#9How does the two-pointer technique work and when does it apply?
#10Explain the sliding window pattern and the difference between fixed and variable windows.
#11What is a prefix sum array and what problem does it solve?
#12How does Kadane's algorithm find the maximum subarray sum?
#13How do you rotate an array by k positions in O(1) space?
#14Why are strings immutable in Java, and what does that mean for algorithm performance?
#15How would you check whether two strings are anagrams?
#16Explain the Dutch National Flag algorithm.
#17How do you find the duplicate number in an array of n+1 integers in the range 1 to n, without modifying it and in O(1) space?
#18What is the difference between a subarray, a subsequence, and a subset?
#19How does a hash table achieve O(1) lookup, and when does it degrade?
#20What is the contract between hashCode() and equals(), and what breaks if you violate it?
Showing 1–20 of 100
Ask Aria about DSA & Coding
Sign in to chat with Aria
All 100 DSA & Coding questions at a glance
- What does Big-O notation actually measure, and what does it deliberately ignore?(Easy)
- What is the difference between Big-O, Big-Omega, and Big-Theta?(Medium)
- Explain amortised complexity using ArrayList as an example.(Medium)
- How do you calculate the space complexity of a recursive function?(Medium)
- Why is O(log n) so much better than O(n), concretely?(Easy)
- What is the difference between an array and a linked list, and when would you pick each?(Easy)
- How would you detect that your algorithm has accidental O(n²) behaviour?(Medium)
- What is the time complexity of building a heap from an array, and why is it not O(n log n)?(Hard)
- How does the two-pointer technique work and when does it apply?(Easy)
- Explain the sliding window pattern and the difference between fixed and variable windows.(Medium)
- What is a prefix sum array and what problem does it solve?(Medium)
- How does Kadane's algorithm find the maximum subarray sum?(Medium)
- How do you rotate an array by k positions in O(1) space?(Medium)
- Why are strings immutable in Java, and what does that mean for algorithm performance?(Easy)
- How would you check whether two strings are anagrams?(Easy)
- Explain the Dutch National Flag algorithm.(Medium)
- How do you find the duplicate number in an array of n+1 integers in the range 1 to n, without modifying it and in O(1) space?(Hard)
- What is the difference between a subarray, a subsequence, and a subset?(Easy)
- How does a hash table achieve O(1) lookup, and when does it degrade?(Medium)
- What is the contract between hashCode() and equals(), and what breaks if you violate it?(Medium)
- Compare separate chaining and open addressing for collision resolution.(Hard)
- How would you find whether any two numbers in an array sum to a target, in one pass?(Easy)
- When would you choose a TreeMap over a HashMap?(Medium)
- How do you group anagrams together efficiently?(Medium)
- How would you find the longest consecutive sequence in an unsorted array in O(n)?(Hard)
- How do you find the longest substring without repeating characters?(Medium)
- How does the three-sum problem work and why is sorting the key step?(Medium)
- How do you solve the trapping rain water problem?(Hard)
- What is a monotonic stack and what problems does it solve?(Hard)
- How do you find the minimum window substring containing all characters of a pattern?(Hard)
- How do you merge two sorted arrays in place when the first has trailing space?(Easy)
- How would you check if a string is a valid palindrome ignoring non-alphanumeric characters?(Easy)
- How do you reverse a linked list, iteratively and recursively?(Easy)
- How does Floyd's cycle detection work, and how do you find where the cycle starts?(Medium)
- Why do linked list problems so often use a dummy head node?(Easy)
- How do you find the middle of a linked list in one pass?(Easy)
- How would you merge two sorted linked lists?(Easy)
- How do you remove the nth node from the end of a list in one pass?(Medium)
- How would you detect the intersection point of two linked lists?(Medium)
- Why is merge sort preferred over quicksort for linked lists?(Medium)
- How would you implement a queue using two stacks?(Medium)
- How do you design a stack that returns the minimum in O(1)?(Medium)
- How do you validate balanced parentheses?(Easy)
- What is a deque and when is it the right structure?(Medium)
- How would you evaluate a postfix (Reverse Polish) expression?(Medium)
- How does a circular queue work and why use one?(Medium)
- How would you find the largest rectangle in a histogram?(Hard)
- What are the tree traversal orders and when is each the right one?(Easy)
- How do you validate that a binary tree is a BST?(Medium)
- What makes a tree balanced, and why does it matter?(Medium)
- How do you find the lowest common ancestor of two nodes in a binary tree?(Medium)
- How would you serialise and deserialise a binary tree?(Hard)
- What is a trie and when would you use one over a hash map?(Medium)
- How do you compute the diameter of a binary tree?(Medium)
- How would you print a binary tree level by level?(Easy)
- What is the difference between a binary heap and a binary search tree?(Medium)
- How do you construct a binary tree from inorder and preorder traversals?(Hard)
- How would you check if two binary trees are identical, and how does that differ from checking for a subtree?(Medium)
- How is a binary heap stored in an array, and why is that possible?(Medium)
- How do you find the k largest elements in a stream of numbers?(Medium)
- How would you find the median of a stream of numbers?(Hard)
- How do you merge k sorted lists efficiently?(Medium)
- What is the difference between a heap and a priority queue?(Easy)
- When do you use BFS versus DFS?(Easy)
- How do you detect a cycle in a directed graph, and why does the undirected approach not work?(Medium)
- What is topological sort and what are the two ways to compute it?(Medium)
- How does Dijkstra's algorithm work and why does it fail with negative weights?(Hard)
- What is Union-Find and what makes it near-constant time?(Hard)
- How do you represent a graph, and which representation should you choose?(Easy)
- How would you find the number of islands in a grid?(Medium)
- What is the difference between Prim's and Kruskal's algorithms?(Hard)
- How would you clone a graph with cycles?(Medium)
- What is a bipartite graph and how do you test for one?(Medium)
- How does A* differ from Dijkstra's algorithm?(Hard)
- Compare quicksort and merge sort.(Medium)
- What does it mean for a sort to be stable, and when does it matter?(Medium)
- When can you sort faster than O(n log n)?(Hard)
- Write binary search and explain the common off-by-one errors.(Easy)
- How do you search in a rotated sorted array?(Medium)
- What is binary search on the answer, and when do you use it?(Hard)
- How does Quickselect find the kth smallest element in O(n) average time?(Hard)
- How would you find the first and last position of a target in a sorted array with duplicates?(Medium)
- What are the components of a correct recursive function?(Easy)
- What is backtracking and how does it differ from brute force?(Medium)
- How do you generate all subsets of a set?(Medium)
- How do you solve the N-Queens problem?(Hard)
- How do you generate all permutations of an array?(Medium)
- When should you convert recursion to iteration?(Medium)
- What two properties must a problem have for dynamic programming to apply?(Medium)
- What is the difference between memoisation and tabulation?(Medium)
- How do you approach the 0/1 knapsack problem?(Hard)
- How do you compute the longest common subsequence of two strings?(Medium)
- How do you solve the coin change problem, and why does greedy fail?(Medium)
- How do you find the longest increasing subsequence efficiently?(Hard)
- How do you identify that a problem needs DP during an interview?(Medium)
- What is the difference between the house robber problem and simple maximum subarray?(Medium)
- When is a greedy algorithm correct, and how do you prove it?(Hard)
- How do you solve the activity selection or meeting rooms problem?(Medium)
- How do you merge overlapping intervals?(Medium)
- What is the difference between greedy and dynamic programming?(Medium)