Killer Problems




  1. Quick sort - Inplace partition
  2. AtoI and ItoA conversion
  3. Base conversion problems
  4. Verify if all the characters in a given string are unique or not
  5. Remove all the duplicates in a given string - Linked HashSet
  6. insertion Sort 
  7. Merge Sort
  8. Binary Search - recursive and non-recursive
  9. Stack - Datastructure - PUSH, POP, PEEK
  10. Queues - DataStructure - INSERT, REMOVE, ...
  11. Circular Queues - "
  12. LInked Lists SLL
  13. Linked Lists DLL
  14. Linked List XOR based LL
  15.  Concatenate two linked lists
  16. Reverse a SLL
  17. Reverse a DLL
  18. Circular SLL
  19. Lowest Common ancestor if an any given two nodes
  20. 2 sorted arrays of non-repeating integers. Find min(abs(x-y))
  21. Maximum value of continours sub sequence Kadane Algorithm
  22. Given repeated sorted array and a number, Tell its first and last idex 
  23. Reverse the words in a given sentence
  24. Find an element in rotated binary sorted array
  25. Find an element that is repeated more than n/2 times
  26. Implement power function (a)b
  27. Check if a given linked list is cyclic or not
  28. Find a pair in an array that sum up to a number 
  29. Reverse a pair of nodes in a SLL
  30. Seggregate odd/even number of nodes in a given Linked list
  31. Find the middle of a SLL
  32. Addition of 2 linked lists
  33. XOR based linked list - Insert, delete and display
  34. Convert SLL to DLL
  35. Circular shift an array of size n
  36. Find the minimum element in a rotated sorted array
  37. Pattern Matching - Rabin Karp Algorithm
  38. K-way merge sort
  39. Maximum Depth or Height a a given tree
  40. Find all the subsets of a given set of integers 
  41. Find the inorder successor a given node in BST
  42. Heapsort
  43. Find the minimum length of unsorted subarray to make whole array as sortd
  44. Suffix arrays
  45. Print all the permutations of a given stirng
  46. Rearrange a stirng such that all the same characters be 'd' distant away
  47. Rat in a Maze 0,0 to 7,7 ?
  48. Find all the subset of elements in a given set whose sum equal to a target
  49. Find if there is a subarray with sum 0
  50. Find the median of given two input sorted arrays
  51. Find the fixe dpoint a[3]=3 or a[1]=1 in a given sorted arary
  52. Count # of key occurrences of a number in sorted array
  53. Check if a given number is a multiple of 3 or not
  54. Check if a number 'n' is power of 2 or not
  55. Function to multiply n by 7
  56. Multiply 2 numbers without * operator
  57. Generate all prime numbers smaller than equal to n [Sieve of Erathosenes]
  58. Make a fair coin from unbiased coin
  59. Print all the possible words from phone digits 
  60. Shuffle a given array / Randomize a given array of integers - Fisher Yates 
  61. Reservior sampling - Select 'k' random elements from a stream with k/n probability
  62. Given a number 'n'. Generate a Pascal Triangle
  63. Generate all prime factors of a given number ;n;
  64. Random number generator in arbitrary probability Distribution function
  65. Check if a given number is fibonacci number or not
  66. Longest common Subsequence
  67. Minimum cost path, Find the cost of traversing from 0.0 to m,n
  68. Coing change problem
  69. Binomial  co-efficient via Pascal Triangle ?
  70. Knapsack problem
  71. Egg drop problem
  72. Longest palindromic subsequence
  73. Palindrome Partitioning. Determine minumum number of cuts to make substrings as palindromes
  74. Partitioning problem - Two sets with equal sum
  75. Maximum length chain of pairs
  76. Check if a given linked list is a palindrome or not [stack or reverse]
  77. Given a post order + Inorder array, Check whether array is BST or not
  78. Array with bits 0110101101, flip them such that it has max number of 1's in it
  79. Implement sizeof() operator
  80. Find inorder successor of a BST
  81. Find all the triangle triplets in an array
  82. Josephus problem
  83. Given a sorted skewed binary tree, createa a BST out of it
  84. Return all elements in an array that are repeated twice only
  85. Given an array, put all even numbers to left of array and odd numbers to right of array
  86. Height of a given tree
  87. Diameter of a given binary tree
  88. Serialize/Deserialize a given binary tree
  89. Find the just single repeated element in a a given array
  90. Implement diff command in linux
  91. Program to count number of 1's in a given number
  92. Convert BST to DLL
  93. Swap variables withour a temp
  94. check if a number is prime or not
  95. GCD of 2 numbers - Euclidean Algorithm
  96. Median of a stream of numbers continous
  97.  Print all the paths of a given binary tree from root to leaf
  98. Modify/Relocate an array such that a[i] = a[a[i]]
  99. Find a missing number in 4 Billion Numbers
  100. Given 'n', Generate all valid paranthesis string of length 2n
  101. Rectangle intersection problem - Find if rectangles overlap and area of rectangles
  102. Dutch National Flag Problem 0-1-2
  103. Increment an arbitrary precision integer, Stored in an array
  104. Advancing through an array to reach end
  105. Delete duplicates from a sorted array
  106. buy and sell a stock once
  107. buy and sell a stock multiple times
  108. permute all the elemtns of an array
  109. Compute next permutation represented 'n' as in an array
  110. Random Sampling 
  111. Sample online data 
  112. Sudoku Checker Problem [Backtracking]
  113. Sudoku Checker Problem - validate if its a correct sudoku
  114. Base Conversion n(b1) to n(b2)
  115. Given a column number, Find the corresponding column name in a excel spreadsheet
  116. Char replacement in a string, Replace 'a' with 'dd', Remove 'b'
  117. Validate if a given sentence is a palindrome or not
  118. Look and Say Sequence, Given n, output nth number in the sequence
  119. convert form roman numeral to decimal number
  120. compute all the valid IP addresses
  121. write a string sinusoidally - since wave fashion
  122. Implement a runlength encoding algorithm
  123. Merge 2 sorted linekd lists
  124. Reverse a sublist of a given linked lists
  125. Verify if a given tree is height balanced or not
  126. Total # of nodes on longest path between 2 leaves in a tree, AKA Diameter of a given tree
  127. Sum root-to-leaf paths in a binary tree
  128. Given a BT, Return true if it has root-to-leaf path sum adding up to all values along the path equal to a given number
  129. Implement inorder traversal without recursion - Morris Traversal
  130. Implement inorder traversal with a stack
  131. Iterative pre-order traversal
  132. Iterative post-order traversal
  133. Compute value of kth smallest node in a binary tree
  134. Reconstruct a binary tree from a given traversal data (inorder + Pre or Post)
  135. Construct a DLL from leaves of a binary tree
  136. Print boundary of a given binary tree
  137. Priority queues using Heaps 
  138. Convert Minheap to Max heap
  139. check if a given binary tree is a heap or not
  140. Check if a given BT is complete or not
  141. Check if a given array represents max heap or not
  142. Given a infinite stream, Find the kth largest element at any point of time
  143. Merge 'k' sorted arrays - external Sorting
  144. Ternary search 
  145. Level order traversal of a binary tree
  146. Heap - Insertion, Deletion to max heap - Priority Queues
  147. Verify if 2 strings are anagrams or not
  148. Longest increasing sub sequence
  149. Given 2 string and operations (insert, delete and replace) can be done on str1, Find the minimum number of edits required to convert str1 to str2
  150. Rod cutting, Max value obatined by cutting rod of 'n' length  + Price and values are considered
  151. Maximum sum increasing subsequence
  152. Longest biotonic subsequence
  153. Floyd Warshall Alogorithm
  154. Minimum number of jumps required to reach end 
  155. Pattern searching - KMP Knuthh Morris Pattern Algo
  156. Given n+2, find the 2 repeated elements from 0 to n 
  157. Lowest common ancestor in a BST
  158. Find inorder predecessor and successor in a BST
  159. Delete a node in BST - 3 cases
  160. merge two BSTs with limited extra space
  161. Find ceil and floor value of a given key in a BST
  162. Binary trees - Full, complete, Perferct, balanced ?
  163. Size of a binary tree
  164. Convert a Binary tree in to its mirror tree Inplace post order
  165. Count # of leaf nodes in a binary tree
  166. Check for childrem sum property in a given binary tree
  167. maximum width of binary tree - i.e find a level that contains maximum number of nodes
  168. Check if a tree is foldable or not
  169. Print all the nodes with distance 'k' apart from the root
  170. Get level of a node in a binary tree
  171. Print ancestors of a given node in binary tree
  172. Check if a binary tree is a subtree of another binary tree
  173. Connect nodes at same level in a binary tree - extended level order
  174. Populate inorder successor nodes of all nodes in a binary tree - Reverse inorder
  175. Convert given tree to its sum tree 
  176. Find the maximum sum from root to leaf in a BT
  177. Print the boundary of a BT
  178.  Construct a Full BT form given pre-order & post order. There are other possible combinations of traversals too
  179. Iterative post-order traversal using stacks
  180. Reverse level order traversal 2 stacks 
  181. Count BST nodes that lie in a given range low, high
  182. Clone a linkedlist with next and random pointer
  183. Wildcard pattern matching . ? *
  184. Implement a stack using  queues 
  185. Implement a queue using stacks
  186. generate a random number in a range
  187. Select a random node in a given SLL
  188. Check if a number is a palindrome or not
  189. Existenece of increasing triplet in a sequence
  190. Sum of all the numbers that are formed from root to leaf path
  191. Find all the possible words in a given word boggle. you can assume a routine being provided to check if a word exists in a dictionary or not
  192. Longest path in a given matrix
  193. Find the peak element in an given array 
  194. Four array sum problem a[i] + b[j] + c[k] + d[l] whose sum is zero
  195. Verify if string 't' is a subsequence of another string 's'
  196. Remove duplicates from sorted arrays. how about if we allow max number of duplicate elements
  197. Submatrix sum queries. Given (r1,c1) and (r2,c2)
  198. Four sum problem such that a+b+c+d = target 
  199. Partition a given linked list with values across 'x'
  200. Find the sum of all digits in a number recursively until it becomes a single digit
  201. Longest continuous/consecutive sub sequence - DP
  202. Implement a trie/prefix trees
  203. Sort a hashMap<k,v> based on values
  204. Sort the elements based on frequence Ex: tree -> eetr
  205.  sum of two number without +,-,*,/
  206. Repeated DNA subsequence maxlength =10, AGCT 
  207. Flight Drone Fuel 
  208. A product array puzzle, a[i] = prod(0-i-1 & r+1 to n)
  209. Word count engine, Given a doc - count number of words
  210. Count number of possible triangles in a given array
  211. Find the # of leaders in a given array
  212. Find the sub array continous sum equal to a target
  213. Find the equilibrium index of a given interger array
  214. Minimum number of paltforms required for a railway station given the arrival and departure of the trains
  215. Find the maximum of all subarrays of size k
  216. Find the kth smallest or kth largest element in a given array
  217. Trapping Rain Water - Find the max amount of water that can be stroed in a given hieght of bridges repesented as an array
  218. Chocolate distribtuion problem - Find the minimum difference such tath every m student gets a packet and the diff of min and max packet received by a student is minimal
  219. Find an elemtn with all left side smaller and all right side elements are greater
  220. Convert a givne unsorted array in to zig zag fashion [a>b<c>d<e>f...]
  221. Relative Sorting - Sort an array according to the order defined by another array
  222. Traverse the matrix in a sprial way
  223. Arrange the given numbers in an array to form the biggest number
  224. Largest sub array with equal number of 0s and 1s
  225. Check if a string has valid set an order of paranthesis
  226. Largest palindrome in a given string
  227. Recursively remove all the adjacent duplicates characters progressively - azxxzy
  228. Check if a given string is rotated by two places
  229. Find the longest common substring in given two strings
  230. Given a string, Find the minimum # of characters to be inserted to convert to a plindrome
  231. Find the longest substring with all distinct characters
  232. Implement a string indexOf method
  233. Given an array of String, Find the longest common prefix
  234. Given an unsorted array. Find the continous subarray that adds upto a target
  235. A special linked list with next and random pointer with each list sorted, Flatten it in sorted order
  236. Find the intersection point or merge point in the linkedlist
  237. Find the next largest element to right of the array
  238. Get the minimum element from  a stack at any given point of time 't'
  239. Given (capacity, distance), Find a starting point to circle the tour
  240. Given infinity stream, Find the first non-repeating character
  241. Print the left view of Binary tree
  242. Print bottom view of binary tree
  243. Print right view of binary tree
  244. Print vertical order of binary tree
  245. Print level order of a tree traversal in spiral form
  246. Print level order of a tree in reversal form
  247. Given a binary tree in which each node contains a number, Find the max possible sum from one leaf node to another leaf node
  248. Find the median in a infinite stream of interegers
  249. Given a string repated characters, the task is to rearrange the chanracters in a string such that no two adjacent characters are same
  250. Given a 2D screen, location of a pixek in a screen and  a color k, Repalce all such pixels with color 'y'
  251. Count all possible paths from top left to right bottom. i,e 0,0 to m,n only right n down directions are allowed
  252. Given an integer array and a target N , Find all the unique combinations in A where sum is equal to target. element can be used only once.
  253. Same as above question, but what if element can be used any nnumber of times
  254. Given n of keystorkes allowed, Find the max A's that can be printed if permissible keystrokes are - ctrl+A, ctrl+c, ctrl+v and A
  255. Find the largest subarray with 0 sum
  256. Given two array of integers,  Find the two arrays sum be equal of swapping atmost one integer ?
  257. Given an array of integers, and window 'k' , Print the count of distinct numbers in all windows of size k
  258. GIA (Given Integer array), Find if an array can be divided in to pairs such that sum of every pair is divisible by 'k'
  259. GIA, Find the length of longest consecutive subsequence
  260. Find if one integer array is subset of another array
  261. Given two unsorted arrays, Find all the pairs from both arrays where sum is equal to x
  262. Find the first repeated character in a given string s
  263. GIA, Print the total count of subarrays with their sum equal to 0
  264. Given a string and pattern, Find the character in a string that is present at minimum index in a second string.
  265. Find the uncommon character of two string . A uncommon character is something i.e present in one string or other but not both
  266. Find the smallest window in a string that contains all characters in another string
  267. GIA, Find the first element that occurs k number of times
  268. Given a string, Check if its possible to remove atmot one character such that frequencies of all characters of each distinct chracter becoms same in a string
  269. Depth first traversal of a graph
  270. Breadth First Traversal of a graph
  271. Detect a cycle in a directed graph
  272. Given set of vertices and edges, Sort them in a topological order
  273. Find the number of islands in a given 0/1 matrix
  274. Find the shortest distance from source to all destination vertices [Djikstra]
  275. Find the minimum number of swaps required to sort an integer array
  276. Given a graph with n nodes and m edges, Find the total number of strongly connected components
  277. Given a binary 0/1 matrix, Find the shortest path that exists from a given source to destination cell (LEE algorithm)
  278. Given n*n matrix with 0,1,2,3. Find whether a path exists from source 1 to destination 2 via cell 3. 0 - means blocked
  279. Circle of Strings, Given a list of strings, Find whether we can form a circle from start and last character ?
  280. Find the minimum number of jumps required to reach end
  281. Find the # of ways to make a change for N cents if infinite supply of coins exist
  282. Find the minimum  coins required to make change for N cents on infinite supply of coins
  283. Partition Problem - Find if an array can be partitioned into two subsets such that their sum is equal
  284. Sort Stack the boxes of N types. Each box has l,d and h. Create a stack of boxes as tall as possible. You can rotate the boxes if needed
  285. Find the longest path in the matrix such that all cells along the path are in increasing order with a difference of 1
  286. same as above but just with increasing path without constraint of diff 1
  287. Find an element that appears only once in sorted order
  288. Find kth element in two sorted arrays
  289. Find the last index of '1' , Given an array of 0s and 1s
  290. Find the first set bit in an integer
  291. Given two integers, Find the right most different bit
  292. Given an integer, Find if kth bit is set from right or not
  293. Check if a given integer is power of 2 or not
  294. Given 2 integers, Find the # of bits differ in each integer
  295. Find the total number os longest consecutive 1's in an integer
  296. Find the most frequesnt word in a given list or array of strings
  297. Find the median of two sorted arrays
  298. Given an array, find the maximum (j-i) such that a[j] >= a[i]
  299. Given a sentence, Output a string by dropping a seen character alternatively.
  300. Find if one can reach end of the array assuming a[i] being the number of cells to jump
  301. Print all the elements in a sorted from a row and columnwise sorted matrix
  302. Search an element in a row and column wise sorted matrix
  303. Regular Expression - Search for a pattern with ? * in the text
  304. Delete a node in the middle of single linked list. Only a pointer to middle node is given
  305. Find the three closest elements from a given three sorted arrays such that a[i]-b[j], b[j]-c[k], c[k]-a[i] is minimum
  306. Find the largest rectangular histogram
  307. Maximum size square of submatrix that has all 1's
  308. Find all the triplets with 0 sum in an array
  309. Max product sub array
  310. Sliding Window Maximum, Find the max of 'k' in window
  311. Largest submatrix sum of size k
  312. Word Boggle - Given a 2D char matrix, Find if the word exists in a given grid.
  313. Word Boggle 2 - Given a dictionary of words, Return all the words that exist in  a grid
  314. Word Break - Given a dictionary of words and a concatenated string, Ensure if you can segement the concat string based on dictionary words
  315. Merge all the overlapping interval pairs
  316. Given 2 sorted lists, merge in to single list by merging intervals
  317. Count the number of ways to reach n stairs
  318. Find the closest leaf node in a Binary tree
  319. Add bold tag in the string
  320. Merge two binary trees
  321. Find the closest time given HH:MM
  322. Reverse an integer
  323. Find the largest value in a tree at each level
  324. Find the # of ways of climbing steps to top . Max of 1-2 stops each time
  325. Find palindrome pairs in a given list of words
  326. Word Square - Find the word [row, column] of fixed length
  327. Set Matrix Zeros - Replace a row and its respective column to 0
  328. Find the median of 'k' elements of sliding window
  329. Word Ladder Problem. Find the minimum traversals in a dictionary to reach target
  330. Find the longest valid parentheses in a given string
  331. Given an integer, Find the possible ways to decode it. a-1, b-2...z-26
  332. Clone a undirected graph
  333. Implement calculator - Given a expression string
  334. Implement a program to version matching. major.minor.subminor
  335. Implement Tic Tac Toe Game
  336. Design and Implement a hit counter
  337. Implement a BST Iterator - hasNext and next
  338. Implement a array iterator - hasnext and next
  339. Implement a list of list iterator - hasnext and next and remove methods
  340. Palindrome Partitioning - Find the minimum number of cuts required to make a string palindrome substrings
  341. Convert an integer to words - similar to how you write in check leaf

Comments

  1. good collection.
    can u provide solutions in java

    ReplyDelete
  2. The answers to these questions should be available online anywhere with a simple google search. But I would recommend you to attempt and think before referring to any solutions up front.

    ReplyDelete

Post a Comment

Popular posts from this blog

sde-interview-ramp-up

Installing YUM on OpenSUSE

Youtkit - Java Profiler