Here are 400+ competitive questions with a solution. If you solve all these questions then we will guaranty you that you can crack any company.

# Topic:- Array

1. Reverse the array
2. Find the maximum and minimum element in an array
3. Find the "Kth" max and min element of an array
4. Given an array which consists of only 0, 1 and 2. Sort the array without using any sorting algo
5. Move all the negative elements to one side of the array
6. Find the Union and Intersection of the two sorted arrays.
7. Write a program to cyclically rotate an array by one.
8. find Largest sum contiguous Subarray [V. IMP]
9. Minimise the maximum difference between heights [V.IMP]
10. Minimum no. of Jumps to reach end of an array
11. find duplicate in an array of N+1 Integers
12. Merge 2 sorted arrays without using Extra space.
14. Merge Intervals
15. Next Permutation
16. Count Inversion
17. Best time to buy and Sell stock
18. find all pairs on integer array whose sum is equal to given number
19. find common elements In 3 sorted arrays
20. Rearrange the array in alternating positive and negative items with O(1) extra space
21. Find if there is any subarray with sum equal to 0
22. Find factorial of a large number
23. find maximum product subarray
24. Find longest coinsecutive subsequence
25. Given an array of size n and a number k, fin all elements that appear more than " n/k " times.
26. Maximum profit by buying and selling a share atmost twice
27. Find whether an array is a subset of another array
28. Find the triplet that sum to a given value
29. Trapping Rain water problem
30. Chocolate Distribution problem
31. Smallest Subarray with sum greater than a given value
32. Three way partitioning of an array around a given value
33. Minimum swaps required bring elements less equal K together
34. Minimum no. of operations required to make an array palindrome
35. Median of 2 sorted arrays of equal size
36. Median of 2 sorted arrays of different size
37. Spiral traversal on a Matrix

38. Search an element in a matriix

39. Find median in a row wise sorted matrix

40. Find row with maximum no. of 1's

41. Print elements in sorted order using row-column wise sorted matrix

42. Maximum size rectangle

43. Find a specific pair in matrix

44. Rotate matrix by 90 degrees

45. Kth smallest element in a row-cpumn wise sorted matrix

46. Common elements in all rows of a given matrix

47. Reverse a String

48. Check whether a String is Palindrome or not

49. Find Duplicate characters in a string

50. Why strings are immutable in Java?

51. Write a Code to check whether one string is a rotation of another

52. Write a Program to check whether a string is a valid shuffle of two strings or not

53. Count and Say problem

54. Write a program to find the longest Palindrome in a string.[ Longest palindromic Substring]

55. Find Longest Recurring Subsequence in String

56. Print all Subsequences of a string.

57. Print all the permutations of the given string

58. Split the Binary string into two substring with equal 0’s and 1’s

59. Word Wrap Problem [VERY IMP].

60. EDIT Distance [Very Imp]

61. Find next greater number with same set of digits. [Very Very IMP]

62. Balanced Parenthesis problem.[Imp]

63. Word break Problem[ Very Imp]

64. Rabin Karp Algo

65. KMP Algo

66. Convert a Sentence into its equivalent mobile numeric keypad sequence.

67. Minimum number of bracket reversals needed to make an expression balanced.

68. Count All Palindromic Subsequence in a given String.

69. Count of number of given string in 2D character array

70. Search a Word in a 2D Grid of characters.

71. Boyer Moore Algorithm for Pattern Searching.

72. Converting Roman Numerals to Decimal

73. Longest Common Prefix

74. Number of flips to make binary string alternate

75. Find the first repeated word in string.

76. Minimum number of swaps for bracket balancing.

77. Find the longest common subsequence between two strings.

78. Program to generate all possible valid IP addresses from given  string.

79. Write a program tofind the smallest window that contains all characters of string itself.

80. Rearrange characters in a string such that no two adjacent are same

81. Minimum characters to be added at front to make string palindrome

82. Given a sequence of words, print all anagrams together

83. Find the smallest window in a string containing all characters of another string

84. Recursively remove all adjacent duplicates

85. String matching where one string contains wildcard characters

86. Function to find Number of customers who could not get a computer

87. Transform One String to Another using Minimum Number of Given Operation

88. Check if two given strings are isomorphic to each other

89. Recursively print all sentences that can be formed from list of word lists

90. Find first and last positions of an element in a sorted array

91. Find a Fixed Point (Value equal to index) in a given array

92. Search in a rotated sorted array

93. square root of an integer

94. Maximum and minimum of an array using minimum number of comparisons

95. Optimum location of point to minimize total distance

96. Find the repeating and the missing

97. find majority element

98. Searching in an array where adjacent differ by at most k

99. find a pair with a given difference

100. find four elements that sum to a given value

101. maximum sum such that no 2 elements are adjacent

102. Count triplet with sum smaller than a given value

103. merge 2 sorted arrays

104. print all subarrays with 0 sum

105. Product array Puzzle

106. Sort array according to count of set bits

107. minimum no. of swaps required to sort the array

108. Bishu and Soldiers

109. Rasta and Kheshtak

110. Kth smallest number again

111. Find pivot element in a sorted array

112. K-th Element of Two Sorted Arrays

113. Aggressive cows

114. Book Allocation Problem

115. EKOSPOJ:

116. Job Scheduling Algo

117. Missing Number in AP

118. Smallest number with atleastn trailing zeroes infactorial

119. Painters Partition Problem:

120. ROTI-Prata SPOJ

121. DoubleHelix SPOJ

122. Subset Sums

123. Findthe inversion count

124. Implement Merge-sort in-place

125. Partitioning and Sorting Arrays with Many Repeated Entries

126. Write a Program to reverse the Linked List. (Both Iterative and recursive)

127. Reverse a Linked List in group of Given Size. [Very Imp]

128. Write a program to Detect loop in a linked list.

129. Write a program to Delete loop in a linked list.

130. Find the starting point of the loop.

131. Remove Duplicates in a sorted Linked List.

132. Remove Duplicates in a Un-sorted Linked List.

133. Write a Program to Move the last element to Front in a Linked List.

136. Intersection of two Sorted Linked List.

137. Intersection Point of two Linked Lists.

138. Merge Sort For Linked lists.[Very Important]

139. Quicksort for Linked Lists.[Very Important]

140. Find the middle Element of a linked list.

142. Split a Circular linked list into two halves.

143. Write a Program to check whether the Singly Linked list is a palindrome or not.

144. Deletion from a Circular Linked List.

145. Reverse a Doubly Linked list.

146. Find pairs with a given sum in a DLL.

147. Count triplets in a sorted DLL whose sum is equal to given value “X”.

148. Sort a “k”sorted Doubly Linked list.[Very IMP]

149. Rotate DoublyLinked list by N nodes.

150. Rotate a Doubly Linked list in group of Given Size.[Very IMP]

151. Can we reverse a linked list in less than O(n) ?

152. Why Quicksort is preferred for. Arrays and Merge Sort for LinkedLists ?

154. Sort a LL of 0's, 1's and 2's

155. Clone a linked list with next and random pointer

156. Merge K sorted Linked list

157. Multiply 2 no. represented by LL

158. Delete nodes which have a greater value on right side

159. Segregate even and odd nodes in a Linked List

160. Program for n’th node from the end of a Linked List

161. Find the first non-repeating character from a stream of characters

162. level order traversal

163. Reverse Level Order traversal

164. Height of a tree

165. Diameter of a tree

166. Mirror of a tree

167. Inorder Traversal of a tree both using recursion and Iteration

168. Preorder Traversal of a tree both using recursion and Iteration

169. Postorder Traversal of a tree both using recursion and Iteration

170. Left View of a tree

171. Right View of Tree

172. Top View of a tree

173. Bottom View of a tree

174. Zig-Zag traversal of a binary tree

175. Check if a tree is balanced or not

176. Diagnol Traversal of a Binary tree

177. Boundary traversal of a Binary tree

178. Construct Binary Tree from String with Bracket Representation

179. Convert Binary tree into Doubly Linked List

180. Convert Binary tree into Sum tree

181. Construct Binary tree from Inorder and preorder traversal

182. Find minimum swaps required to convert a Binary tree into BST

183. Check if Binary tree is Sum tree or not

184. Check if all leaf nodes are at same level or not

185. Check if a Binary Tree contains duplicate subtrees of size 2 or more [ IMP ]

186. Check if 2 trees are mirror or not

187. Sum of Nodes on the Longest path from root to leaf node

188. Check if given graph is tree or not.  [ IMP ]

189. Find Largest subtree sum in a tree

190. Maximum Sum of nodes in Binary tree such that no two are adjacent

191. Print all "K" Sum paths in a Binary tree

192. Find LCA in a Binary tree

193. Find distance between 2 nodes in a Binary tree

194. Kth Ancestor of node in a Binary tree

195. Find all Duplicate subtrees in a Binary tree [ IMP ]

196. Tree Isomorphism Problem

197. Fina a value in a BST

198. Deletion of a node in a BST

199. Find min and max value in a BST

200. Find inorder successor and inorder predecessor in a BST

201. Check if a tree is a BST or not

202. Populate Inorder successor of all nodes

203. Find LCA  of 2 nodes in a BST

204. Construct BST from preorder traversal

205. Convert Binary tree into BST

206. Convert a normal BST into a Balanced BST

207. Merge two BST [ V.V.V>IMP ]

208. Find Kth largest element in a BST

209. Find Kth smallest element in a BST

210. Count pairs from 2 BST whose sum is equal to given value "X"

211. Find the median of BST in O(n) time and O(1) space

212. Count BST ndoes that lie in a given range

213. Replace every element with the least greater element on its right

214. Given "n" appointments, find the conflicting appointments

215. Check preorder is valid or not

216. Check whether BST contains Dead end

217. Largest BST in a Binary Tree [ V.V.V.V.V IMP ]

218. Flatten BST to sorted list

219. Activity Selection Problem

220. Job SequencingProblem

221. Huffman Coding

222. Water Connection Problem

223. Fractional Knapsack Problem

224. Greedy Algorithm to find Minimum number of Coins

225. Maximum trains for which stoppage can be provided

226. Minimum Platforms Problem

227. Buy Maximum Stocks if i stocks can be bought on i-th day

228. Find the minimum and maximum amount to buy all N candies

229. Minimize Cash Flow among a given set of friends who have borrowed money from each other

230. Minimum Cost to cut a board into squares

231. Check if it is possible to survive on Island

232. Find maximum meetings in one room

233. Maximum product subset of an array

234. Maximize array sum after K negations

235. Maximize the sum of arr[i]*i

236. Maximum sum of absolute difference of an array

237. Maximize sum of consecutive differences in a circular array

238. Minimum sum of absolute difference of pairs of two arrays

239. Program for Shortest Job First (or SJF) CPU Scheduling

240. Program for Least Recently Used (LRU) Page Replacement algorithm

241. Smallest subset with sum greater than all other elements

242. Chocolate Distribution Problem

243. DEFKIN -Defense of a Kingdom

244. DIEHARD -DIE HARD

245. GERGOVIA -Wine trading in Gergovia

246. Picking Up Chicks

247. CHOCOLA –Chocolate

248. ARRANGE -Arranging Amplifiers

249. K Centers Problem

250. Minimum Cost of ropes

251. Find smallest number with given number of digits and sum of digits

252. Rearrange characters in a string such that no two adjacent are same

253. Find maximum sum possible equal sum of three stacks

254. Rat in a maze Problem

255. Printing all solutions in N-Queen Problem

256. Word Break Problem using Backtracking

257. Remove Invalid Parentheses

258. Sudoku Solver

259. m Coloring Problem

260. Print all palindromic partitions of a string

261. Subset Sum Problem

262. The Knight’s tour problem

263. Tug of War

264. Find shortest safe route in a path with landmines

265. Combinational Sum

266. Find Maximum number possible by doing at-most K swaps

267. Print all permutations of a string

268. Find if there is a path of more than k length from a source

269. Longest Possible Route in a Matrix with Hurdles

270. Print all possible paths from top left to bottom right of a mXn matrix

271. Partition of a set intoK subsets with equal sum

272. Find the K-th Permutation Sequence of first N natural numbers

273.  Implement Stack from Scratch

274.  Implement Queue from Scratch

275. Implement 2 stack in an array

276. find the middle element of a stack

277. Implement "N" stacks in an Array

278. Check the expression has valid or Balanced parenthesis or not.

279. Reverse a String using Stack

280. Design a Stack that supports getMin() in O(1) time and O(1) extra space.

281. Find the next Greater element

282. The celebrity Problem

283. Arithmetic Expression evaluation

284. Evaluation of Postfix expression

285. Implement a method to insert an element at its bottom without using any other data structure.

286. Reverse a stack using recursion

287. Sort a Stack using recursion

288. Merge Overlapping Intervals

289. Largest rectangular Area in Histogram

290. Length of the Longest Valid Substring

291. Expression contains redundant bracket or not

292. Implement Stack using Queue

293. Implement Stack using Deque

294. Stack Permutations (Check if an array is stack permutation of other)

295. Implement Queue using Stack

296. Implement "n" queue in an array

297. Implement a Circular queue

298. LRU Cache Implementationa

299. Reverse a Queue using recursion

300. Reverse the first “K” elements of a queue

301. Interleave the first half of the queue with second half

302. Find the first circular tour that visits all Petrol Pumps

303. Minimum time required to rot all oranges

304. Distance of nearest cell having 1 in a binary matrix

305. First negative integer in every window of size “k”

306. Check if all levels of two trees are anagrams or not.

307. Sum of minimum and maximum elements of all subarrays of size “k”.

308. Minimum sum of squares of character counts in a given string after removing “k” characters.

309. Queue based approach or first non-repeating character in a stream.

310. Next Smaller Element

311. Implement a Maxheap/MinHeap using arrays and recursion.

312. Sort an Array using heap. (HeapSort)

313. Maximum of all subarrays of size k.

314. “k” largest element in an array

315. Kth smallest and largest element in an unsorted array

316. Merge “K” sorted arrays. [ IMP ]

317. Merge 2 Binary Max Heaps

318. Kth largest sum continuous subarrays

319. Leetcode- reorganize strings

320. Merge “K” Sorted Linked Lists [V.IMP]

321. Smallest range in “K” Lists

322. Median in a stream of Integers

323. Check if a Binary Tree is Heap

324. Connect “n” ropes with minimum cost

325. Convert BST to Min Heap

326. Convert min heap to max heap

327. Rearrange characters in a string such that no two adjacent are same.

328. Minimum sum of two numbers formed from digits of an array

329. Create a Graph, print it

330. Implement BFS algorithm

331. Implement DFS Algo

332. Detect Cycle in Directed Graph using BFS/DFS Algo

333. Detect Cycle in UnDirected Graph using BFS/DFS Algo

334. Search in a Maze

335. Minimum Step by Knight

336. flood fill algo

337. Clone a graph

338. Making wired Connections

340. Dijkstra algo

341. Implement Topological Sort

342. Minimum time taken by each job to be completed given by a Directed Acyclic Graph

343. Find whether it is possible to finish all tasks or not from given dependencies

344. Find the no. of Isalnds

345. Given a sorted Dictionary of an Alien Language, find order of characters

346. Implement Kruksal’sAlgorithm

347. Implement Prim’s Algorithm

348. Total no. of Spanning tree in a graph

349. Implement Bellman Ford Algorithm

350. Implement Floyd warshallAlgorithm

351. Travelling Salesman Problem

352. Graph ColouringProblem

354. Find bridge in a graph

355. Count Strongly connected Components(Kosaraju Algo)

356. Check whether a graph is Bipartite or Not

357. Detect Negative cycle in a graph

358. Longest path in a Directed Acyclic Graph

359. Journey to the Moon

360. Cheapest Flights Within K Stops

361. Oliver and the Game

362. Water Jug problem using BFS

363. Water Jug problem using BFS

364. Find if there is a path of more thank length from a source

365. M-ColouringProblem

366. Minimum edges to reverse o make path from source to destination

367. Paths to travel each nodes using each edge(Seven Bridges)

368. Vertex Cover Problem

369. Chinese Postman or Route Inspection

370. Number of Triangles in a Directed and Undirected Graph

371. Minimise the cashflow among a given set of friends who have borrowed money from each other

372. Two Clique Problem

373. Construct a trie from scratch

374. Find shortest unique prefix for every word in a given list

375. Word Break Problem | (Trie solution)

376. Given a sequence of words, print all anagrams together

377. Implement a Phone Directory

378. Print unique rows in a given boolean matrix

379. Coin ChangeProblem

380. Knapsack Problem

381. Binomial CoefficientProblem

382. Permutation CoefficientProblem

383. Program for nth Catalan Number

384. Matrix Chain Multiplication

385. Edit Distance

386. Subset Sum Problem

387. Friends Pairing Problem

388. Gold Mine Problem

389. Assembly Line SchedulingProblem

390. Painting the Fenceproblem

391. Maximize The Cut Segments

392. Longest Common Subsequence

393. Longest Repeated Subsequence

394. Longest Increasing Subsequence

395. Space Optimized Solution of LCS

396. LCS (Longest Common Subsequence) of three strings

397. Maximum Sum Increasing Subsequence

398. Count all subsequences having product less than K

399. Longest subsequence such that difference between adjacent is one

400. Maximum subsequence sum such that no three are consecutive

401. Egg Dropping Problem

402. Maximum Length Chain of Pairs

403. Maximum size square sub-matrix with all 1s

404. Maximum sum of pairs with specific difference

405. Min Cost PathProblem

406. Maximum difference of zeros and ones in binary string

407. Minimum number of jumps to reach end

408. Minimum cost to fill given weight in a bag

409. Minimum removals from array to make max –min <= K

410. Longest Common Substring

411. Count number of ways to reacha given score in a game

412. Count Balanced Binary Trees of Height h

413. LargestSum Contiguous Subarray [V>V>V>V IMP ]

414. Smallest sum contiguous subarray

415. Unbounded Knapsack (Repetition of items allowed)

416. Word Break Problem

417. Largest Independent Set Problem

418. Partition problem

419. Longest Palindromic Subsequence

420. Count All Palindromic Subsequence in a given String

421. Longest Palindromic Substring

422. Longest alternating subsequence

423. Weighted Job Scheduling

424. Coin game winner where every player has three choices

425. Count Derangements (Permutation such that no element appears in its original position) [ IMPORTANT ]

426. Maximum profit by buying and selling a share at most twice [ IMP ]

427. Optimal Strategy for a Game

428. Optimal Binary Search Tree

429. Palindrome PartitioningProblem

430. Word Wrap Problem

431. Mobile Numeric Keypad Problem [ IMP ]

432. Boolean Parenthesization Problem

433. Largest rectangular sub-matrix whose sum is 0

434. Largest area rectangular sub-matrix with equal number of 1’s and 0’s [ IMP ]

435. Maximum sum rectangle in a 2D matrix

436. Maximum profit by buying and selling a share at most k times

437. Find if a string is interleaved of two other strings

438. Maximum Length of Pair Chain

439. Count set bits in an integer

440. Find the two non-repeating elements in an array of repeating elements

441. Count number of bits to be flipped to convert A to B

442. Count total set bits in all numbers from 1 to n

443. Program to find whether a no is power of two

444. Find position of the only set bit

445. Copy set bits in a range

446. Divide two integers without using multiplication, division and mod operator

447. Calculate square of a number without using *, / and pow()

448. Power Set

Many More Comming soon...