101 questions in 9 topics
DSA Basics Interview Questions
The basics asked in campus placements: the core structures, how they differ, and short array and string problems.
- What is a data structure, and what is an algorithm?
- What is the difference between linear and non-linear data structures?
- What is the difference between an array and a linked list?
- What is the difference between a stack and a queue?
Time and Space Complexity Interview Questions
Big O, the cost of loops and recursion, and the complexity of common Python operations.
- What is Big O notation?
- How many passes does a Python loop take to halve 64 down to 1?
- How many times does a nested loop over
range(i, n)run, and what is its Big O? - What is space complexity, and does recursion use extra space?
Array and String Interview Questions
Two pointers, sliding windows, prefix sums and the in-place tricks behind most array and string questions.
- What is the two pointer technique, and when do you use it?
- What is the sliding window technique?
- How does Kadane's algorithm find the maximum subarray sum?
- What is a prefix sum, and what problems does it solve?
Linked List, Stack and Queue Interview Questions
Linked list pointer work, stacks and queues, heaps as priority queues, and the LRU cache.
- How do you reverse a singly linked list?
- How do you detect a cycle in a linked list?
- How do you find the middle of a linked list in one pass?
- What is the difference between singly, doubly and circular linked lists?
Hashing Interview Questions
How hash tables work, collisions, and the hash map patterns that turn O(n²) searches into one pass.
- What is a hash table, and why is lookup O(1)?
- How do you solve two sum in O(n)?
- What is a hash collision, and how is it handled?
- Can
1,1.0andTruebe separate keys in a Python dict?
Tree and Graph Interview Questions
Traversals, BSTs, BFS and DFS, topological sort, shortest paths, tries and union find.
- What is the difference between a binary tree and a binary search tree?
- What are full, complete, perfect and balanced binary trees?
- What are inorder, preorder and postorder traversals?
- In what order does a preorder traversal visit this five-node tree?
Sorting and Searching Interview Questions
Sorting trade-offs, binary search and its variants, and selecting the k-th element.
- Compare the common sorting algorithms by time, space and stability.
- How do you implement binary search, and what are the common bugs?
- What is the difference between merge sort and quick sort?
- How does quick sort's partition work, and how do you avoid the O(n²) worst case?
Dynamic Programming Interview Questions
Spotting a DP problem, memoization against tabulation, and the classics: knapsack, LIS, LCS and edit distance.
- What is dynamic programming?
- How many calls does a naive recursive
fib(10)make in Python? - What is the difference between memoization and tabulation?
- What is the difference between greedy and dynamic programming? Show a case where greedy fails.
DSA Coding Interview Questions
Complete solutions to common coding problems, each with the edge case to raise.
- How do you find the maximum profit from buying and selling a stock once?
- How do you find the majority element (more than n/2 occurrences) in O(1) space?
- How do you find the longest substring without repeating characters?
- How do you merge overlapping intervals?
Frequently Asked Questions
How do I prepare for a DSA interview?
Learn patterns, not individual problems. Go one topic at a time: arrays and strings, hashing, two pointers, stacks and queues, linked lists, binary search, trees, graphs, heaps, then dynamic programming. Solve easy problems until the pattern is routine, then medium ones, and redo failed problems a week later.
Which DSA topics are asked most for freshers and campus placements?
Arrays, strings, hashing, stacks and queues, linked lists, basic recursion, sorting, binary search and Big O. Trees and simple BFS or DFS often come in later rounds. Prepare one easy DP problem, such as house robber.
What is asked in DSA interviews for experienced developers?
The same topics at medium and hard difficulty, with more graphs, heaps, dynamic programming and design questions such as an LRU cache. You are expected to reach a good solution faster and explain trade-offs without hints.
Which programming language should I use for DSA interviews?
The one you write fastest and most correctly; most interviews let you choose. Python is short and has deque, heapq and Counter built in, and Java and C++ are equally accepted. Know your language's collections and their complexities.
How long does it take to prepare DSA for interviews?
If you already program comfortably, a few months of an hour or two a day usually covers easy and medium questions. From zero it takes longer, since you first need fluency in one language. Consistency matters more than the number of problems solved.