Here you get a free Data Structure Interview Question which helps you to Give Correct Answer of the Question in the Interview. It also helps you for you college exams Preparation.
Basic of DSA
- Explain the Running Sum of 1D Array in DSA.
- How Shuffle the Array in DSA ???
- Explain the Fibonacci Numbers in DSA.
- Explain the Reversing a String in DSA.
- Explain the Search Insert Position in DSA.
- Explain Jewels and Stones in DSA.
Arrays and Matrices
- Find the maximum Sum Subarray using Divide and Conquer.
- Implement an algorithm to find the submatrix with the maximum sum.
- Rotate a square matrix by 90 degrees in-place.
- Find the median of two sorted arrays of different sizes.
- Find all subarrays with a given XOR value.
- Implement the Kadane’s algorithm for a 2D matrix.
- Find the smallest range that includes elements from K sorted arrays.
- Find the majority element in an array using the Boyer-Moore algorithm.
- Determine if a Sudoku puzzle is valid.
- Implement the Strassen’s Matrix Multiplication algorithm.
Strings
- Find the longest palindromic substring using Manacher’s algorithm.
- Implement KMP (Knuth-Morris-Pratt) pattern matching algorithm.
- Find the shortest superstring containing all given strings.
- Solve the “Edit Distance” problem using Dynamic Programming.
- Count distinct substrings of a string using a Trie.
- Implement Rabin-Karp for pattern searching with rolling hash.
- Find the lexicographically smallest rotation of a string.
- Check if a string can be rearranged into a palindrome.
- Find the minimum number of characters to insert to make a string palindrome.
- Perform a Z-algorithm for pattern matching.
Linked Lists
- Reverse a linked list in groups of K.
- Detect and remove a loop in a linked list.
- Merge K sorted linked lists into one sorted list.
- Flatten a multilevel doubly linked list.
- Clone a linked list with random pointers.
- Find the intersection point of two linked lists.
- Add two numbers represented by linked lists.
- Rotate a linked list by K nodes.
- Find the starting node of the cycle in a linked list.
- Merge two sorted linked lists without recursion.
Stacks and Queues
- Implement a stack that supports
getMin()
in O(1). - Sort a stack using recursion.
- Implement a queue using two stacks.
- Find the maximum element in each sliding window of size K.
- Evaluate a postfix expression using a stack.
- Implement an LRU Cache using a Doubly Linked List.
- Check for balanced parentheses using a stack.
- Find the largest rectangle in a histogram.
- Implement a monotonic stack for finding the next greater element.
- Design a circular queue with dynamic resizing.
Trees
- Serialize and Deserialize a binary tree.
- Find the Lowest Common Ancestor in a binary tree.
- Implement a Segment Tree for range sum queries.
- Check if a binary tree is height-balanced.
- Construct a binary tree from its preorder and inorder traversals.
- Convert a binary tree to its mirror image.
- Find the diameter of a binary tree.
- Implement the Morris Traversal for in-order traversal.
- Find the maximum path sum in a binary tree.
- Design an AVL tree with insertion and deletion.
Binary Search Trees (BST)
- Find the Kth smallest/largest element in a BST.
- Implement a BST iterator with O(1) average time per operation.
- Validate if a given tree is a BST.
- Convert a BST to a balanced BST.
- Construct a BST from a sorted array.
- Find pairs with a given sum in a BST.
- Merge two BSTs into a balanced BST.
- Delete a node in a BST.
- Invert a BST.
- Find the inorder successor/predecessor in a BST.
Heaps and Priority Queues
- Implement a max heap and min heap.
- Find the Kth largest element in a stream.
- Merge K sorted arrays using a heap.
- Implement a median-finding data structure.
- Check if a binary tree is a heap.
- Find the smallest range that includes elements from K lists.
- Solve the “Task Scheduler” problem.
- Reorganize a string such that no two adjacent characters are the same.
- Find the top K frequent elements in an array.
- Implement a heap sort algorithm.
Graphs
- Implement Dijkstra’s algorithm for the shortest path.
- Find the bridges in a graph using Tarjan’s algorithm.
- Solve the “Travelling Salesman Problem” using dynamic programming.
- Implement Kruskal’s algorithm for Minimum Spanning Tree.
- Check if a graph is bipartite.
- Find all strongly connected components using Kosaraju’s algorithm.
- Solve the “Word Ladder” problem using BFS.
- Implement Prim’s algorithm for Minimum Spanning Tree.
- Perform a topological sort using Kahn’s algorithm.
- Find the shortest path in a weighted DAG.
Dynamic Programming
- Solve the “Longest Increasing Subsequence” problem.
- Solve the “0/1 Knapsack” problem.
- Find the number of ways to decode a message.
- Implement the “Egg Dropping Problem”.
- Solve the “Longest Palindromic Subsequence” problem.
- Count the number of ways to partition a set into subsets.
- Solve the “Matrix Chain Multiplication” problem.
- Find the minimum cost to paint houses with a color constraint.
- Solve the “Wildcard Matching” problem.
- Solve the “Subset Sum” problem.
Greedy Algorithms
- Solve the “Activity Selection” problem.
- Implement Huffman Encoding for data compression.
- Find the minimum number of platforms required for a railway station.
- Solve the “Fractional Knapsack” problem.
- Find the minimum spanning tree using Kruskal’s algorithm.
- Solve the “Job Sequencing Problem”.
- Determine the optimal strategy for the “Gas Station” problem.
- Implement the “Interval Partitioning” problem.
- Solve the “Optimal File Merge Pattern”.
- Find the minimum cost to connect ropes.
Backtracking
- Solve the N-Queens problem.
- Find all subsets of a set.
- Solve the “Sudoku Solver” problem.
- Solve the “Rat in a Maze” problem.
- Find all permutations of a string or array.
- Solve the “Word Break” problem using backtracking.
- Implement a Knight’s Tour problem.
- Solve the “Partition Equal Subset Sum” problem.
- Find all combinations that sum to a given value.
- Solve the “Hamiltonian Path” problem.