450+ DSA Interview Questions

Topic Problem Name
1Array Reverse the array
2Array Find the maximum and minimum element in an array
3Array Find the "Kth" max and min element of an array 
4Array Given an array which consists of only 0, 1 and 2. Sort the array without using any sorting algo
5Array Move all the negative elements to one side of the array 
6Array Find the Union and Intersection of the two sorted arrays.
7Array Write a program to cyclically rotate an array by one.
8Array find Largest sum contiguous Subarray [V. IMP]
9Array Minimise the maximum difference between heights [V.IMP]
10Array Minimum no. of Jumps to reach end of an array
11Array find duplicate in an array of N+1 Integers
12Array Merge 2 sorted arrays without using Extra space.
13Array Kadane's Algo [V.V.V.V.V IMP]
14Array Merge Intervals
15Array Next Permutation
16Array Count Inversion
17Array Best time to buy and Sell stock
18Array find all pairs on integer array whose sum is equal to given number
19Array find common elements In 3 sorted arrays
20Array Rearrange the array in alternating positive and negative items with O(1) extra space
21Array Find if there is any subarray with sum equal to 0
22Array Find factorial of a large number
23Array find maximum product subarray 
24Array Find longest coinsecutive subsequence
25Array Given an array of size n and a number k, fin all elements that appear more than " n/k " times.
26Array Maximum profit by buying and selling a share atmost twice
27Array Find whether an array is a subset of another array
28Array Find the triplet that sum to a given value
29Array Trapping Rain water problem
30Array Chocolate Distribution problem
31Array Smallest Subarray with sum greater than a given value
32Array Three way partitioning of an array around a given value
33Array Minimum swaps required bring elements less equal K together
34Array Minimum no. of operations required to make an array palindrome
35Array Median of 2 sorted arrays of equal size
36Array Median of 2 sorted arrays of different size
37Matrix Spiral traversal on a Matrix
38Matrix Search an element in a matriix
39Matrix Find median in a row wise sorted matrix
40Matrix Find row with maximum no. of 1's
41Matrix Print elements in sorted order using row-column wise sorted matrix
42Matrix Maximum size rectangle
43Matrix Find a specific pair in matrix
44Matrix Rotate matrix by 90 degrees
45Matrix Kth smallest element in a row-cpumn wise sorted matrix
46Matrix Common elements in all rows of a given matrix
47String Reverse a String
48String Check whether a String is Palindrome or not
49String Find Duplicate characters in a string
50String Why strings are immutable in Java?
51String Write a Code to check whether one string is a rotation of another
52String Write a Program to check whether a string is a valid shuffle of two strings or not
53String Count and Say problem
54String Write a program to find the longest Palindrome in a string.[ Longest palindromic Substring]
55String Find Longest Recurring Subsequence in String
56String Print all Subsequences of a string.
57String Print all the permutations of the given string
58String Split the Binary string into two substring with equal 0’s and 1’s
59String Word Wrap Problem [VERY IMP].
60String EDIT Distance [Very Imp]
61String Find next greater number with same set of digits. [Very Very IMP]
62String Balanced Parenthesis problem.[Imp]
63String Word break Problem[ Very Imp]
64String Rabin Karp Algo
65String KMP Algo
66String Convert a Sentence into its equivalent mobile numeric keypad sequence.
67String Minimum number of bracket reversals needed to make an expression balanced.
68String Count All Palindromic Subsequence in a given String.
69String Count of number of given string in 2D character array
70String Search a Word in a 2D Grid of characters.
71String Boyer Moore Algorithm for Pattern Searching.
72String Converting Roman Numerals to Decimal
73String Longest Common Prefix
74String Number of flips to make binary string alternate
75String Find the first repeated word in string.
76String Minimum number of swaps for bracket balancing.
77String Find the longest common subsequence between two strings.
78String Program to generate all possible valid IP addresses from given  string.
79String Write a program tofind the smallest window that contains all characters of string itself.
80String Rearrange characters in a string such that no two adjacent are same
81String Minimum characters to be added at front to make string palindrome
82String Given a sequence of words, print all anagrams together
83String Find the smallest window in a string containing all characters of another string
84String Recursively remove all adjacent duplicates
85String String matching where one string contains wildcard characters
86String Function to find Number of customers who could not get a computer
87String Transform One String to Another using Minimum Number of Given Operation
88String Check if two given strings are isomorphic to each other
89String Recursively print all sentences that can be formed from list of word lists
90
91Searching & Sorting Find first and last positions of an element in a sorted array
92Searching & Sorting Find a Fixed Point (Value equal to index) in a given array
93Searching & Sorting Search in a rotated sorted array
94Searching & Sorting square root of an integer
95Searching & Sorting Maximum and minimum of an array using minimum number of comparisons
96Searching & Sorting Optimum location of point to minimize total distance
97Searching & Sorting Find the repeating and the missing
98Searching & Sorting find majority element
99Searching & Sorting Searching in an array where adjacent differ by at most k
100Searching & Sorting find a pair with a given difference
101Searching & Sorting find four elements that sum to a given value
102Searching & Sorting maximum sum such that no 2 elements are adjacent
103Searching & Sorting Count triplet with sum smaller than a given value
104Searching & Sorting merge 2 sorted arrays
105Searching & Sorting print all subarrays with 0 sum
106Searching & Sorting Product array Puzzle
107Searching & Sorting Sort array according to count of set bits
108Searching & Sorting minimum no. of swaps required to sort the array
109Searching & Sorting Bishu and Soldiers
110Searching & Sorting Rasta and Kheshtak
111Searching & Sorting Kth smallest number again
112Searching & Sorting Find pivot element in a sorted array
113Searching & Sorting K-th Element of Two Sorted Arrays
114Searching & Sorting Aggressive cows
115Searching & Sorting Book Allocation Problem
116Searching & Sorting EKOSPOJ:
117Searching & Sorting Job Scheduling Algo
118Searching & Sorting Missing Number in AP
119Searching & Sorting Smallest number with atleastn trailing zeroes infactorial
120Searching & Sorting Painters Partition Problem:
121Searching & Sorting ROTI-Prata SPOJ
122Searching & Sorting DoubleHelix SPOJ
123Searching & Sorting Subset Sums
124Searching & Sorting Findthe inversion count
125Searching & Sorting Implement Merge-sort in-place
126Searching & Sorting Partitioning and Sorting Arrays with Many Repeated Entries
127
128LinkedList Write a Program to reverse the Linked List. (Both Iterative and recursive)
129LinkedList Reverse a Linked List in group of Given Size. [Very Imp]
130LinkedList Write a program to Detect loop in a linked list.
131LinkedList Write a program to Delete loop in a linked list.
132LinkedList Find the starting point of the loop. 
133LinkedList Remove Duplicates in a sorted Linked List.
134LinkedList Remove Duplicates in a Un-sorted Linked List.
135LinkedList Write a Program to Move the last element to Front in a Linked List.
136LinkedList Add “1” to a number represented as a Linked List.
137LinkedList Add two numbers represented by linked lists.
138LinkedList Intersection of two Sorted Linked List.
139LinkedList Intersection Point of two Linked Lists.
140LinkedList Merge Sort For Linked lists.[Very Important]
141LinkedList Quicksort for Linked Lists.[Very Important]
142LinkedList Find the middle Element of a linked list.
143LinkedList Check if a linked list is a circular linked list.
144LinkedList Split a Circular linked list into two halves.
145LinkedList Write a Program to check whether the Singly Linked list is a palindrome or not.
146LinkedList Deletion from a Circular Linked List.
147LinkedList Reverse a Doubly Linked list.
148LinkedList Find pairs with a given sum in a DLL.
149LinkedList Count triplets in a sorted DLL whose sum is equal to given value “X”.
150LinkedList Sort a “k”sorted Doubly Linked list.[Very IMP]
151LinkedList Rotate DoublyLinked list by N nodes.
152LinkedList Rotate a Doubly Linked list in group of Given Size.[Very IMP]
153LinkedList Can we reverse a linked list in less than O(n) ?
154LinkedList Why Quicksort is preferred for. Arrays and Merge Sort for LinkedLists ?
155LinkedList Flatten a Linked List
156LinkedList Sort a LL of 0's, 1's and 2's
157LinkedList Clone a linked list with next and random pointer
158LinkedList Merge K sorted Linked list
159LinkedList Multiply 2 no. represented by LL
160LinkedList Delete nodes which have a greater value on right side
161LinkedList Segregate even and odd nodes in a Linked List
162LinkedList Program for n’th node from the end of a Linked List
163LinkedList Find the first non-repeating character from a stream of characters
164
165Binary Trees level order traversal
166Binary Trees Reverse Level Order traversal
167Binary Trees Height of a tree
168Binary Trees Diameter of a tree
169Binary Trees Mirror of a tree
170Binary Trees Inorder Traversal of a tree both using recursion and Iteration
171Binary Trees Preorder Traversal of a tree both using recursion and Iteration
172Binary Trees Postorder Traversal of a tree both using recursion and Iteration
173Binary Trees Left View of a tree
174Binary Trees Right View of Tree
175Binary Trees Top View of a tree
176Binary Trees Bottom View of a tree
177Binary Trees Zig-Zag traversal of a binary tree
178Binary Trees Check if a tree is balanced or not
179Binary Trees Diagnol Traversal of a Binary tree
180Binary Trees Boundary traversal of a Binary tree
181Binary Trees Construct Binary Tree from String with Bracket Representation
182Binary Trees Convert Binary tree into Doubly Linked List
183Binary Trees Convert Binary tree into Sum tree
184Binary Trees Construct Binary tree from Inorder and preorder traversal
185Binary Trees Find minimum swaps required to convert a Binary tree into BST
186Binary Trees Check if Binary tree is Sum tree or not
187Binary Trees Check if all leaf nodes are at same level or not
188Binary Trees Check if a Binary Tree contains duplicate subtrees of size 2 or more [ IMP ]
189Binary Trees Check if 2 trees are mirror or not
190Binary Trees Sum of Nodes on the Longest path from root to leaf node 
191Binary Trees Check if given graph is tree or not.  [ IMP ]
192Binary Trees Find Largest subtree sum in a tree
193Binary Trees Maximum Sum of nodes in Binary tree such that no two are adjacent 
194Binary Trees Print all "K" Sum paths in a Binary tree
195Binary Trees Find LCA in a Binary tree
196Binary Trees Find distance between 2 nodes in a Binary tree
197Binary Trees Kth Ancestor of node in a Binary tree
198Binary Trees Find all Duplicate subtrees in a Binary tree [ IMP ]
199Binary Trees Tree Isomorphism Problem
200Binary Search Trees Fina a value in a BST
201Binary Search Trees Deletion of a node in a BST
202Binary Search Trees Find min and max value in a BST
203Binary Search Trees Find inorder successor and inorder predecessor in a BST
204Binary Search Trees Check if a tree is a BST or not 
205Binary Search Trees Populate Inorder successor of all nodes
206Binary Search Trees Find LCA  of 2 nodes in a BST
207Binary Search Trees Construct BST from preorder traversal
208Binary Search Trees Convert Binary tree into BST
209Binary Search Trees Convert a normal BST into a Balanced BST
210Binary Search Trees Merge two BST [ V.V.V>IMP ]
211Binary Search Trees Find Kth largest element in a BST
212Binary Search Trees Find Kth smallest element in a BST
213Binary Search Trees Count pairs from 2 BST whose sum is equal to given value "X"
214Binary Search Trees Find the median of BST in O(n) time and O(1) space
215Binary Search Trees Count BST ndoes that lie in a given range
216Binary Search Trees Replace every element with the least greater element on its right
217Binary Search Trees Given "n" appointments, find the conflicting appointments
218Binary Search Trees Check preorder is valid or not
219Binary Search Trees Check whether BST contains Dead end
220Binary Search Trees Largest BST in a Binary Tree [ V.V.V.V.V IMP ]
221Binary Search Trees Flatten BST to sorted list
222Greedy Activity Selection Problem
223Greedy Job SequencingProblem
224Greedy Huffman Coding
225Greedy Water Connection Problem
226Greedy Fractional Knapsack Problem
227Greedy Greedy Algorithm to find Minimum number of Coins
228Greedy Maximum trains for which stoppage can be provided
229Greedy Minimum Platforms Problem
230Greedy Buy Maximum Stocks if i stocks can be bought on i-th day
231Greedy Find the minimum and maximum amount to buy all N candies
232Greedy Minimize Cash Flow among a given set of friends who have borrowed money from each other
233Greedy Minimum Cost to cut a board into squares
234Greedy Check if it is possible to survive on Island
235Greedy Find maximum meetings in one room
236Greedy Maximum product subset of an array
237Greedy Maximize array sum after K negations
238Greedy Maximize the sum of arr[i]*i
239Greedy Maximum sum of absolute difference of an array
240Greedy Maximize sum of consecutive differences in a circular array
241Greedy Minimum sum of absolute difference of pairs of two arrays
242Greedy Program for Shortest Job First (or SJF) CPU Scheduling
243Greedy Program for Least Recently Used (LRU) Page Replacement algorithm
244Greedy Smallest subset with sum greater than all other elements
245Greedy Chocolate Distribution Problem
246Greedy DEFKIN -Defense of a Kingdom
247Greedy DIEHARD -DIE HARD
248Greedy GERGOVIA -Wine trading in Gergovia
249Greedy Picking Up Chicks
250Greedy CHOCOLA –Chocolate
251Greedy ARRANGE -Arranging Amplifiers
252Greedy K Centers Problem
253Greedy Minimum Cost of ropes
254Greedy Find smallest number with given number of digits and sum of digits
255Greedy Rearrange characters in a string such that no two adjacent are same
256Greedy Find maximum sum possible equal sum of three stacks
257BackTracking Rat in a maze Problem
258BackTracking Printing all solutions in N-Queen Problem
259BackTracking Word Break Problem using Backtracking
260BackTracking Remove Invalid Parentheses
261BackTracking Sudoku Solver
262BackTracking m Coloring Problem
263BackTracking Print all palindromic partitions of a string
264BackTracking Subset Sum Problem
265BackTracking The Knight’s tour problem
266BackTracking Tug of War
267BackTracking Find shortest safe route in a path with landmines
268BackTracking Combinational Sum
269BackTracking Find Maximum number possible by doing at-most K swaps
270BackTracking Print all permutations of a string 
271BackTracking Find if there is a path of more than k length from a source
272BackTracking Longest Possible Route in a Matrix with Hurdles
273BackTracking Print all possible paths from top left to bottom right of a mXn matrix
274BackTracking Partition of a set intoK subsets with equal sum
275BackTracking Find the K-th Permutation Sequence of first N natural numbers
276Stacks & Queues  Implement Stack from Scratch
277Stacks & Queues  Implement Queue from Scratch
278Stacks & Queues Implement 2 stack in an array
279Stacks & Queues find the middle element of a stack
280Stacks & Queues Implement "N" stacks in an Array
281Stacks & Queues Check the expression has valid or Balanced parenthesis or not.
282Stacks & Queues Reverse a String using Stack
283Stacks & Queues Design a Stack that supports getMin() in O(1) time and O(1) extra space.
284Stacks & Queues Find the next Greater element
285Stacks & Queues The celebrity Problem
286Stacks & Queues Arithmetic Expression evaluation
287Stacks & Queues Evaluation of Postfix expression
288Stacks & Queues Implement a method to insert an element at its bottom without using any other data structure.
289Stacks & Queues Reverse a stack using recursion
290Stacks & Queues Sort a Stack using recursion
291Stacks & Queues Merge Overlapping Intervals
292Stacks & Queues Largest rectangular Area in Histogram
293Stacks & Queues Length of the Longest Valid Substring
294Stacks & Queues Expression contains redundant bracket or not
295Stacks & Queues Implement Stack using Queue
296Stacks & Queues Implement Stack using Deque
297Stacks & Queues Stack Permutations (Check if an array is stack permutation of other)
298Stacks & Queues Implement Queue using Stack  
299Stacks & Queues Implement "n" queue in an array
300Stacks & Queues Implement a Circular queue
301Stacks & Queues LRU Cache Implementationa
302Stacks & Queues Reverse a Queue using recursion
303Stacks & Queues Reverse the first “K” elements of a queue
304Stacks & Queues Interleave the first half of the queue with second half
305Stacks & Queues Find the first circular tour that visits all Petrol Pumps
306Stacks & Queues Minimum time required to rot all oranges
307Stacks & Queues Distance of nearest cell having 1 in a binary matrix
308Stacks & Queues First negative integer in every window of size “k”
309Stacks & Queues Check if all levels of two trees are anagrams or not.
310Stacks & Queues Sum of minimum and maximum elements of all subarrays of size “k”.
311Stacks & Queues Minimum sum of squares of character counts in a given string after removing “k” characters.
312Stacks & Queues Queue based approach or first non-repeating character in a stream.
313Stacks & Queues Next Smaller Element
314Heap Implement a Maxheap/MinHeap using arrays and recursion.
315Heap Sort an Array using heap. (HeapSort)
316Heap Maximum of all subarrays of size k.
317Heap “k” largest element in an array
318Heap Kth smallest and largest element in an unsorted array
319Heap Merge “K” sorted arrays. [ IMP ]
320Heap Merge 2 Binary Max Heaps
321Heap Kth largest sum continuous subarrays
322Heap Leetcode- reorganize strings
323Heap Merge “K” Sorted Linked Lists [V.IMP]
324Heap Smallest range in “K” Lists
325Heap Median in a stream of Integers
326Heap Check if a Binary Tree is Heap
327Heap Connect “n” ropes with minimum cost
328Heap Convert BST to Min Heap
329Heap Convert min heap to max heap
330Heap Rearrange characters in a string such that no two adjacent are same.
331Heap Minimum sum of two numbers formed from digits of an array
332Graph Create a Graph, print it
333Graph Implement BFS algorithm 
334Graph Implement DFS Algo 
335Graph Detect Cycle in Directed Graph using BFS/DFS Algo 
336Graph Detect Cycle in UnDirected Graph using BFS/DFS Algo 
337Graph Search in a Maze
338Graph Minimum Step by Knight
339Graph flood fill algo
340Graph Clone a graph
341Graph Making wired Connections
342Graph word Ladder 
343Graph Dijkstra algo
344Graph Implement Topological Sort 
345Graph Minimum time taken by each job to be completed given by a Directed Acyclic Graph
346Graph Find whether it is possible to finish all tasks or not from given dependencies
347Graph Find the no. of Isalnds
348Graph Given a sorted Dictionary of an Alien Language, find order of characters
349Graph Implement Kruksal’sAlgorithm
350Graph Implement Prim’s Algorithm
351Graph Total no. of Spanning tree in a graph
352Graph Implement Bellman Ford Algorithm
353Graph Implement Floyd warshallAlgorithm
354Graph Travelling Salesman Problem
355Graph Graph ColouringProblem
356Graph Snake and Ladders Problem
357Graph Find bridge in a graph
358Graph Count Strongly connected Components(Kosaraju Algo)
359Graph Check whether a graph is Bipartite or Not
360Graph Detect Negative cycle in a graph
361Graph Longest path in a Directed Acyclic Graph
362Graph Journey to the Moon
363Graph Cheapest Flights Within K Stops
364Graph Oliver and the Game
365Graph Water Jug problem using BFS
366Graph Water Jug problem using BFS
367Graph Find if there is a path of more thank length from a source
368Graph M-ColouringProblem
369Graph Minimum edges to reverse o make path from source to destination
370Graph Paths to travel each nodes using each edge(Seven Bridges)
371Graph Vertex Cover Problem
372Graph Chinese Postman or Route Inspection
373Graph Number of Triangles in a Directed and Undirected Graph
374Graph Minimise the cashflow among a given set of friends who have borrowed money from each other
375Graph Two Clique Problem
376Trie Construct a trie from scratch
377Trie Find shortest unique prefix for every word in a given list
378Trie Word Break Problem | (Trie solution)
379Trie Given a sequence of words, print all anagrams together
380Trie Implement a Phone Directory
381Trie Print unique rows in a given boolean matrix
382Dynamic Programming Coin ChangeProblem
383Dynamic Programming Knapsack Problem
384Dynamic Programming Binomial CoefficientProblem
385Dynamic Programming Permutation CoefficientProblem
386Dynamic Programming Program for nth Catalan Number
387Dynamic Programming Matrix Chain Multiplication 
388Dynamic Programming Edit Distance
389Dynamic Programming Subset Sum Problem
390Dynamic Programming Friends Pairing Problem
391Dynamic Programming Gold Mine Problem
392Dynamic Programming Assembly Line SchedulingProblem
393Dynamic Programming Painting the Fenceproblem
394Dynamic Programming Maximize The Cut Segments
395Dynamic Programming Longest Common Subsequence
396Dynamic Programming Longest Repeated Subsequence
397Dynamic Programming Longest Increasing Subsequence
398Dynamic Programming Space Optimized Solution of LCS
399Dynamic Programming LCS (Longest Common Subsequence) of three strings
400Dynamic Programming Maximum Sum Increasing Subsequence
401Dynamic Programming Count all subsequences having product less than K
402Dynamic Programming Longest subsequence such that difference between adjacent is one
403Dynamic Programming Maximum subsequence sum such that no three are consecutive
404Dynamic Programming Egg Dropping Problem
405Dynamic Programming Maximum Length Chain of Pairs
406Dynamic Programming Maximum size square sub-matrix with all 1s
407Dynamic Programming Maximum sum of pairs with specific difference
408Dynamic Programming Min Cost PathProblem
409Dynamic Programming Maximum difference of zeros and ones in binary string
410Dynamic Programming Minimum number of jumps to reach end
411Dynamic Programming Minimum cost to fill given weight in a bag
412Dynamic Programming Minimum removals from array to make max –min <= K
413Dynamic Programming Longest Common Substring
414Dynamic Programming Count number of ways to reacha given score in a game
415Dynamic Programming Count Balanced Binary Trees of Height h
416Dynamic Programming LargestSum Contiguous Subarray [V>V>V>V IMP ]
417Dynamic Programming Smallest sum contiguous subarray
418Dynamic Programming Unbounded Knapsack (Repetition of items allowed)
419Dynamic Programming Word Break Problem
420Dynamic Programming Largest Independent Set Problem
421Dynamic Programming Partition problem
422Dynamic Programming Longest Palindromic Subsequence
423Dynamic Programming Count All Palindromic Subsequence in a given String
424Dynamic Programming Longest Palindromic Substring
425Dynamic Programming Longest alternating subsequence
426Dynamic Programming Weighted Job Scheduling
427Dynamic Programming Coin game winner where every player has three choices
428Dynamic Programming Count Derangements (Permutation such that no element appears in its original position) [ IMPORTANT ]
429Dynamic Programming Maximum profit by buying and selling a share at most twice [ IMP ]
430Dynamic Programming Optimal Strategy for a Game
431Dynamic Programming Optimal Binary Search Tree
432Dynamic Programming Palindrome PartitioningProblem
433Dynamic Programming Word Wrap Problem
434Dynamic Programming Mobile Numeric Keypad Problem [ IMP ]
435Dynamic Programming Boolean Parenthesization Problem
436Dynamic Programming Largest rectangular sub-matrix whose sum is 0
437Dynamic Programming Largest area rectangular sub-matrix with equal number of 1’s and 0’s [ IMP ]
438Dynamic Programming Maximum sum rectangle in a 2D matrix
439Dynamic Programming Maximum profit by buying and selling a share at most k times
440Dynamic Programming Find if a string is interleaved of two other strings
441Dynamic Programming Maximum Length of Pair Chain
442Bit Manipulation Count set bits in an integer
443Bit Manipulation Find the two non-repeating elements in an array of repeating elements
444Bit Manipulation Count number of bits to be flipped to convert A to B
445Bit Manipulation Count total set bits in all numbers from 1 to n
446Bit Manipulation Program to find whether a no is power of two
447Bit Manipulation Find position of the only set bit
448Bit Manipulation Copy set bits in a range
449Bit Manipulation Divide two integers without using multiplication, division and mod operator
450Bit Manipulation Calculate square of a number without using *, / and pow()
451Bit Manipulation Power Set