Home/Interview Prep/DSA & Coding

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.

ComplexityTrees & GraphsDPTwo PointersSortingAria-powered explanations
0 / 100 answered
0%
22 Easy56 Medium22 Hard

Showing 120 of 100

#1What does Big-O notation actually measure, and what does it deliberately ignore?

Easy
Complexity

#2What is the difference between Big-O, Big-Omega, and Big-Theta?

Medium
Complexity

#3Explain amortised complexity using ArrayList as an example.

Medium
Complexity

#4How do you calculate the space complexity of a recursive function?

Medium
Complexity

#5Why is O(log n) so much better than O(n), concretely?

Easy
Complexity

#6What is the difference between an array and a linked list, and when would you pick each?

Easy
Fundamentals

#7How would you detect that your algorithm has accidental O(n²) behaviour?

Medium
Complexity

#8What is the time complexity of building a heap from an array, and why is it not O(n log n)?

Hard
Complexity

#9How does the two-pointer technique work and when does it apply?

Easy
Arrays & Strings

#10Explain the sliding window pattern and the difference between fixed and variable windows.

Medium
Arrays & Strings

#11What is a prefix sum array and what problem does it solve?

Medium
Arrays & Strings

#12How does Kadane's algorithm find the maximum subarray sum?

Medium
Arrays & Strings

#13How do you rotate an array by k positions in O(1) space?

Medium
Arrays & Strings

#14Why are strings immutable in Java, and what does that mean for algorithm performance?

Easy
Arrays & Strings

#15How would you check whether two strings are anagrams?

Easy
Arrays & Strings

#16Explain the Dutch National Flag algorithm.

Medium
Arrays & Strings

#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?

Hard
Arrays & Strings

#18What is the difference between a subarray, a subsequence, and a subset?

Easy
Arrays & Strings

#19How does a hash table achieve O(1) lookup, and when does it degrade?

Medium
Hashing

#20What is the contract between hashCode() and equals(), and what breaks if you violate it?

Medium
Hashing

Showing 120 of 100

Ask Aria about DSA & Coding

Sign in to chat with Aria

All 100 DSA & Coding questions at a glance
  1. What does Big-O notation actually measure, and what does it deliberately ignore?(Easy)
  2. What is the difference between Big-O, Big-Omega, and Big-Theta?(Medium)
  3. Explain amortised complexity using ArrayList as an example.(Medium)
  4. How do you calculate the space complexity of a recursive function?(Medium)
  5. Why is O(log n) so much better than O(n), concretely?(Easy)
  6. What is the difference between an array and a linked list, and when would you pick each?(Easy)
  7. How would you detect that your algorithm has accidental O(n²) behaviour?(Medium)
  8. What is the time complexity of building a heap from an array, and why is it not O(n log n)?(Hard)
  9. How does the two-pointer technique work and when does it apply?(Easy)
  10. Explain the sliding window pattern and the difference between fixed and variable windows.(Medium)
  11. What is a prefix sum array and what problem does it solve?(Medium)
  12. How does Kadane's algorithm find the maximum subarray sum?(Medium)
  13. How do you rotate an array by k positions in O(1) space?(Medium)
  14. Why are strings immutable in Java, and what does that mean for algorithm performance?(Easy)
  15. How would you check whether two strings are anagrams?(Easy)
  16. Explain the Dutch National Flag algorithm.(Medium)
  17. 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)
  18. What is the difference between a subarray, a subsequence, and a subset?(Easy)
  19. How does a hash table achieve O(1) lookup, and when does it degrade?(Medium)
  20. What is the contract between hashCode() and equals(), and what breaks if you violate it?(Medium)
  21. Compare separate chaining and open addressing for collision resolution.(Hard)
  22. How would you find whether any two numbers in an array sum to a target, in one pass?(Easy)
  23. When would you choose a TreeMap over a HashMap?(Medium)
  24. How do you group anagrams together efficiently?(Medium)
  25. How would you find the longest consecutive sequence in an unsorted array in O(n)?(Hard)
  26. How do you find the longest substring without repeating characters?(Medium)
  27. How does the three-sum problem work and why is sorting the key step?(Medium)
  28. How do you solve the trapping rain water problem?(Hard)
  29. What is a monotonic stack and what problems does it solve?(Hard)
  30. How do you find the minimum window substring containing all characters of a pattern?(Hard)
  31. How do you merge two sorted arrays in place when the first has trailing space?(Easy)
  32. How would you check if a string is a valid palindrome ignoring non-alphanumeric characters?(Easy)
  33. How do you reverse a linked list, iteratively and recursively?(Easy)
  34. How does Floyd's cycle detection work, and how do you find where the cycle starts?(Medium)
  35. Why do linked list problems so often use a dummy head node?(Easy)
  36. How do you find the middle of a linked list in one pass?(Easy)
  37. How would you merge two sorted linked lists?(Easy)
  38. How do you remove the nth node from the end of a list in one pass?(Medium)
  39. How would you detect the intersection point of two linked lists?(Medium)
  40. Why is merge sort preferred over quicksort for linked lists?(Medium)
  41. How would you implement a queue using two stacks?(Medium)
  42. How do you design a stack that returns the minimum in O(1)?(Medium)
  43. How do you validate balanced parentheses?(Easy)
  44. What is a deque and when is it the right structure?(Medium)
  45. How would you evaluate a postfix (Reverse Polish) expression?(Medium)
  46. How does a circular queue work and why use one?(Medium)
  47. How would you find the largest rectangle in a histogram?(Hard)
  48. What are the tree traversal orders and when is each the right one?(Easy)
  49. How do you validate that a binary tree is a BST?(Medium)
  50. What makes a tree balanced, and why does it matter?(Medium)
  51. How do you find the lowest common ancestor of two nodes in a binary tree?(Medium)
  52. How would you serialise and deserialise a binary tree?(Hard)
  53. What is a trie and when would you use one over a hash map?(Medium)
  54. How do you compute the diameter of a binary tree?(Medium)
  55. How would you print a binary tree level by level?(Easy)
  56. What is the difference between a binary heap and a binary search tree?(Medium)
  57. How do you construct a binary tree from inorder and preorder traversals?(Hard)
  58. How would you check if two binary trees are identical, and how does that differ from checking for a subtree?(Medium)
  59. How is a binary heap stored in an array, and why is that possible?(Medium)
  60. How do you find the k largest elements in a stream of numbers?(Medium)
  61. How would you find the median of a stream of numbers?(Hard)
  62. How do you merge k sorted lists efficiently?(Medium)
  63. What is the difference between a heap and a priority queue?(Easy)
  64. When do you use BFS versus DFS?(Easy)
  65. How do you detect a cycle in a directed graph, and why does the undirected approach not work?(Medium)
  66. What is topological sort and what are the two ways to compute it?(Medium)
  67. How does Dijkstra's algorithm work and why does it fail with negative weights?(Hard)
  68. What is Union-Find and what makes it near-constant time?(Hard)
  69. How do you represent a graph, and which representation should you choose?(Easy)
  70. How would you find the number of islands in a grid?(Medium)
  71. What is the difference between Prim's and Kruskal's algorithms?(Hard)
  72. How would you clone a graph with cycles?(Medium)
  73. What is a bipartite graph and how do you test for one?(Medium)
  74. How does A* differ from Dijkstra's algorithm?(Hard)
  75. Compare quicksort and merge sort.(Medium)
  76. What does it mean for a sort to be stable, and when does it matter?(Medium)
  77. When can you sort faster than O(n log n)?(Hard)
  78. Write binary search and explain the common off-by-one errors.(Easy)
  79. How do you search in a rotated sorted array?(Medium)
  80. What is binary search on the answer, and when do you use it?(Hard)
  81. How does Quickselect find the kth smallest element in O(n) average time?(Hard)
  82. How would you find the first and last position of a target in a sorted array with duplicates?(Medium)
  83. What are the components of a correct recursive function?(Easy)
  84. What is backtracking and how does it differ from brute force?(Medium)
  85. How do you generate all subsets of a set?(Medium)
  86. How do you solve the N-Queens problem?(Hard)
  87. How do you generate all permutations of an array?(Medium)
  88. When should you convert recursion to iteration?(Medium)
  89. What two properties must a problem have for dynamic programming to apply?(Medium)
  90. What is the difference between memoisation and tabulation?(Medium)
  91. How do you approach the 0/1 knapsack problem?(Hard)
  92. How do you compute the longest common subsequence of two strings?(Medium)
  93. How do you solve the coin change problem, and why does greedy fail?(Medium)
  94. How do you find the longest increasing subsequence efficiently?(Hard)
  95. How do you identify that a problem needs DP during an interview?(Medium)
  96. What is the difference between the house robber problem and simple maximum subarray?(Medium)
  97. When is a greedy algorithm correct, and how do you prove it?(Hard)
  98. How do you solve the activity selection or meeting rooms problem?(Medium)
  99. How do you merge overlapping intervals?(Medium)
  100. What is the difference between greedy and dynamic programming?(Medium)