Huge collection of Array Interview Questions

An array is a data structure consisting of a collection of elements (values or variables), each identified by at least one array index or key. The simplest type of data structure is a linear array, also called one-dimensional array.

Arrays are among the oldest and most important data structures, and are used by almost every program. They are also used to implement many other data structures, such as lists, heaps, hash tables, deques, queues, stacks, strings.

In this post, we have list out commonly asked interview questions that uses array data structure –


  1. Find pair with given sum in the array
  2. Check if subarray with 0 sum is exists or not
  3. Print all sub-arrays with 0 sum
  4. Sort binary array in linear time
  5. Find a duplicate element in a limited range array
  6. Find largest sub-array formed by consecutive integers
  7. Find maximum length sub-array having given sum
  8. Find maximum length sub-array having equal number of 0’s and 1’s
  9. Sort an array containing 0’s, 1’s and 2’s (Dutch national flag problem)
  10. Inplace merge two sorted arrays
  11. Merge two arrays by satisfying given constraints
  12. Find index of 0 to replace to get maximum length sequence of continuous ones
  13. Find maximum product of two integers in an array
  14. Shuffle a given array of elements (Fisher–Yates shuffle)
  15. Rearrange the array with alternate high and low elements
  16. Find equilibrium index of an array
  17. Find majority element in an array (Boyer–Moore majority vote algorithm)
  18. Move all zeros present in the array to the end
  19. Replace each element of array with product of every other element without using / operator
  20. Find Longest Bitonic Subarray in an array
  21. Find maximum difference between two elements in the array by satisfying given constraints
  22. Maximum subarray problem (Kadane’s algorithm)
  23. Print continuous subarray with maximum sum
  24. Maximum Sum Circular Subarray
  25. Find all distinct combinations of given length
  26. Find all distinct combinations of given length with repetition allowed
  27. Find maximum sequence of continuous 1’s formed by replacing at-most k zeroes by ones
  28. Find minimum sum subarray of given size k
  29. Find subarray having given sum in given array of integers
  30. Find the length of smallest subarray whose sum of elements is greater than the given number
  31. Find largest number possible from set of given numbers
  32. Find the smallest window in array sorting which will make the entire array sorted
  33. Find maximum sum path involving elements of given arrays
  34. Maximum profit earned by buying and selling shares any number of times
  35. Trapping Rain Water within given set of bars
  36. Longest Increasing Subsequence
  37. Longest Decreasing Subsequence Problem
  38. Find maximum product subarray in a given array
  39. Find maximum sum of subsequence with no adjacent elements
  40. Find minimum platforms needed in the station so to avoid any delay in arrival of any train
  41. Decode the array constructed from another array
  42. Sort an array using one swap
  43. Find Triplet with given sum in an array
  44. Length of longest continuous sequence with same sum in given binary arrays
  45. Rearrange array such that A[A[i]] is set to i for every element A[i]
  46. Reverse every consecutive m elements of the given subarray
  47. Maximum Product Subset Problem
  48. Find pairs with given difference k in the array
  49. Find pairs with given difference k in the array | Constant space solution
  50. 4 sum problem | Quadruplets with given sum
  51. Print all quadruplets with given sum | 4-sum problem extended
  52. Find odd occurring element in an array in single traversal
  53. Find two odd occurring element in an array without using any extra space
  54. Quickselect Algorithm
  55. Print all Triplets that forms Arithmetic Progression
  56. Print all triplets that forms Geometric Progression
  57. Print all combination of numbers from 1 to n having sum n
  58. Replace each element of the array by its corresponding rank in the array
  59. Print all Triplets in an array with sum less than or equal to given number
  60. Group elements of an array based on their first occurrence
  61. Find minimum difference between index of two given elements present in the array
  62. Find maximum absolute difference between sum of two non-overlapping sub-arrays
  63. Find all Symmetric Pairs in an Array of Pairs
  64. Partition an array into two sub-arrays with the same sum
  65. Find count of distinct elements in every sub-array of size k
  66. Find two numbers with maximum sum formed by array digits
  67. Print all sub-arrays of an array having distinct elements
  68. Find a Triplet having Maximum Product in an Array
  69. Find ways to calculate a target from elements of specified array
  70. Find Minimum Index of Repeating Element in an Array
  71. Generate Random Input from an Array according to given Probabilities
  72. Find pair in an array having minimum absolute sum
  73. Find Index of Maximum Occurring Element with Equal Probability
  74. Check if an Array is Formed by Consecutive Integers
  75. Find two non-overlapping pairs having same sum in an array
  76. Find Minimum Product among all Combinations of Triplets in an Array
  77. Replace every element of an array with the least greater element on its right
  78. Find all odd occurring elements in an array having limited range of elements
  79. Add elements of two arrays into a new array
  80. Count the distinct absolute values in the sorted array
  81. Print all combinations of positive integers in increasing order that sum to a given number
  82. Find all distinct combinations of given length – Part 2
  83. Find subarrays with given sum in an array
  84. Find the surpasser count for each element of an array
  85. Find maximum length sequence of continuous ones (Using Sliding Window)
  86. Find maximum length sequence of continuous ones
  87. Calculate frequency of all elements present in an array of specified range in linear time and using constant space
  88. Rearrange the array such that it contains positive and negative numbers at alternate positions
  89. Merging Overlapping Intervals
  90. Activity Selection Problem
  91. Job Sequencing Problem with Deadlines
  92. Introduction to Priority Queues using Binary Heaps
  93. Min Heap and Max Heap Implementation in C++
  94. Min Heap and Max Heap Implementation in Java
  95. Heap Sort (Out-of-place and In-place implementation in C++ and C)
  96. Check if given array represents min heap or not
  97. Convert Max Heap to Min Heap in linear time
  98. Find K’th largest element in an array
  99. Sort a K-Sorted Array
  100. Merge M sorted lists of variable length
  101. Find K’th smallest element in an array
  102. Find smallest range with at-least one element from each of the given lists
  103. Merge M sorted lists each containing N elements
  104. Insertion sort | Iterative & Recursive
  105. Selection sort | Iterative & Recursive
  106. Bubble sort | Iterative & Recursive
  107. Merge Sort
  108. Quicksort
  109. Iterative Implementation of Quicksort
  110. Hybrid QuickSort
  111. Quicksort using Dutch National Flag Algorithm
  112. Quick Sort using Hoare’s Partitioning scheme
  113. External merge sort
  114. Custom Sort | Sort elements by their frequency and Index
  115. Custom Sort | Sort elements of the array by order of elements defined by the second array
  116. Inversion Count of an array
  117. Segregate positive and negative integers in linear time
  118. Binary Search
  119. Ternary Search vs Binary search
  120. Interpolation search
  121. Exponential search
  122. Find number of rotations in a circularly sorted array
  123. Search an element in a circular sorted array
  124. Find first or last occurrence of a given number in a sorted array
  125. Count occurrences of a number in a sorted array with duplicates
  126. Find smallest missing element from a sorted array
  127. Find Floor and Ceil of a number in a sorted array
  128. Search in a nearly sorted array in O(log(n)) time
  129. Find number of 1’s in a sorted binary array
  130. Find the peak element in an array
  131. Maximum Sum Subarray using Divide & Conquer
  132. Find Minimum and Maximum element in an array using minimum comparisons
  133. Matrix Chain Multiplication
  134. 0-1 Knapsack problem
  135. Maximize value of the expression
  136. Partition problem
  137. Subset sum problem
  138. Minimum Sum Partition problem
  139. Rod Cutting
  140. Coin change-making problem (unlimited supply of coins)
  141. Coin Change Problem (Total number of ways to get the denomination of coins)
  142. Longest alternating subsequence
  143. Combinations of words formed by replacing given numbers with corresponding alphabets
  144. Decode the given sequence to construct minimum number without repeated digits
  145. All combinations of elements satisfying given constraints
  146. Find Missing Term in a Sequence in log(n) time
  147. Print all distinct Subsets of a given Set
  148. Find Floor and Ceil of a number in a sorted array (Recursive solution)
  149. Set both elements of a binary array to 0 in single line
  150. K-Partition Problem | Printing all Partitions
  151. 3 Partition Problem
  152. 3-partition problem extended | Print all partitions
  153. Iterative Merge Sort Algorithm (Bottom-up Merge Sort)
  154. Find two duplicate elements in an limited range array (using XOR)
  155. Find missing number and duplicate elements in an array
  156. Find Minimum and Maximum element in an array by doing minimum comparisons
  157. Find Frequency of each element in a sorted array containing duplicates
  158. Difference between Subarray, Subsequence and Subset


Thank you for being with us. 🙂


Leave a Reply

Notify of