40 most frequently asked DSA questions - FAME-DEV/Java-Test GitHub Wiki
Ready to ace your next interview? Here's a curated list of 40 most frequently asked DSA questions to help you prepare:
Arrays & Strings
- 1️⃣ Find the maximum sum subarray.
- 2️⃣ Identify all palindrome substrings in a string.
- 3️⃣ Solve the "two sum" problem.
- 4️⃣ Implement Kadane's algorithm for maximum subarray sum.
- 5️⃣ Locate the missing number in an array.
- 6️⃣ Merge two sorted arrays into one.
- 7️⃣ Check if a given string is a palindrome.
- 8️⃣ Find the first non-repeating character in a string.
- 9️⃣ Remove duplicates from a sorted array.
Linked Lists
- 🔟 Reverse a linked list.
- 1️⃣1️⃣ Detect a cycle in a linked list.
- 1️⃣2️⃣ Find the middle node of a linked list.
- 1️⃣3️⃣ Merge two sorted linked lists.
- 1️⃣4️⃣ Implement a stack using a linked list.
- 1️⃣5️⃣ Find the intersection point of two linked lists.
Stacks & Queues
- 1️⃣6️⃣ Implement a stack using arrays.
- 1️⃣7️⃣ Design a stack that retrieves the minimum element efficiently.
- 1️⃣8️⃣ Implement a circular queue.
- 1️⃣9️⃣ Create a max stack with support for maximum retrieval.
- 2️⃣0️⃣ Build a queue using stacks.
Trees & Binary Search Trees
- 2️⃣1️⃣ Calculate the height of a binary tree.
- 2️⃣2️⃣ Find the lowest common ancestor of two nodes.
- 2️⃣3️⃣ Verify if a binary tree is a valid binary search tree.
- 2️⃣4️⃣ Serialize and deserialize a binary tree.
- 2️⃣5️⃣ Implement inorder traversal of a binary tree.
- 2️⃣6️⃣ Compute the diameter of a binary tree.
- 2️⃣7️⃣ Convert a binary tree into its mirror image.
Graphs
- 2️⃣8️⃣ Implement depth-first search (DFS).
- 2️⃣9️⃣ Implement breadth-first search (BFS).
- 3️⃣0️⃣ Find the shortest path in an unweighted graph.
- 3️⃣1️⃣ Detect a cycle in an undirected graph using DFS.
- 3️⃣2️⃣ Check if a graph is bipartite.
- 3️⃣3️⃣ Count connected components in an undirected graph.
- 3️⃣4️⃣ Identify bridges in a graph.
Sorting & Searching
- 3️⃣5️⃣ Implement bubble, insertion, selection, and merge sort.
- 3️⃣6️⃣ Implement quicksort.
- 3️⃣7️⃣ Write a binary search algorithm.
- 3️⃣8️⃣ Implement interpolation search.
- 3️⃣9️⃣ Find the kth smallest element in an array.
- 4️⃣0️⃣ Count the number of inversions in an array.