Array Interview Questions
Arrays interview questions are the favorite topic of Microsoft, Amazon, Google, VMWare, etc. We are providing the list of questions on Arrays which will help you to challenge the interviewers. Below are the questions on array data structure. Array algorithm questions are the first choice of interviewers. Below are important array questions for technical interviews. You can write code in java or c++ accourding to your choice.
Write a program to reverse an array. This interview question is very common where interviewer wants to see whether you are capable of writing an optimized program to reverse an array. This program can be written in C++ or Java programming language.
Pair Sum Equals Number
You have to write a program to find the pair of elements from a given array whose sum is equal to a number provided. This interview question is commonly asked the question during technical interviews.
Floor and Ceil
Write a program to find the floor and ceil in the array provided. The floor is just greater and ceil is a just smallest number from the provided number. This question is also asked to test your logical skills in programming.
Largest Sum Subarray
Write a program to find the subarray with the largest sum. This array interview question is asked to check whether you are aware of Kadane's algorithm or not. You can choose java or C++ to write the code.
Write a program to find the missing number from the array. This array interview question is a common question asked in technical interviews of most of the companies. Here interviewer is interested to know whether you are aware of XOR operations on array elements or not.
Odd Occurring Number
Write a program to find the number from an array which is occurring an odd number of times. This question is also a common question for interviews. Here in this question interviewer again wants to see whether you can apply XOR operations on elements of an array or not.
Sort by Frequency
Here you have to write a program/code to sort the elements of an array based on the frequency of their occurrences. This question is commonly asked interview questions on arrays. You can opt any language like Java or C++.
First and Second Smallest
Write a program to find two elements from an array which are smallest among all the elements of an array. This is also a commonly asked technical question on arrays.
Write a program to find the majority element from an array. Majority element is the number which is occurring more than half of the size of the array. A lot of users go with sorting the arrays. This is another set of common array questions asked during technical interviews. You can write a program in any language like C++ or Java.
Difference between elements
Write a program to find the maximum difference between two elements in the array such that larger element occurs after the smaller one. Here interviewer is interested to see your approach based on dynamic programming. This interview question should be answered using dynamic programming. You can opt java or c++ to write the code.
Arrange Even and Odd
Given an array of integers write a program to re-arrange numbers in such a way that odd number comes after even numbers. Here interviewer wants to see your approach to answering this question using two pointers or indices one pointing the first element and second pointing to last element. This is a commonly asked question in the technical interview. You can write a program in any language like c++ or java.
Closest Sum Elements
Write a program in C++ or java to find the closest sum of any two elements of an array which is equal to the given number. This question is being asked in various interviews.
Write a program in any language like C++ or java to find the distinct elements from an array. This array interview question is asked to see whether can you find unique elements from the provided array of elements?
First Repeating Number
You have to write a program to find the first repeating number from an array. There can be various repeating numbers in an array but you need to find the first number which is occurring the second time. This is again a good array interview question to see the implementation of Hashtable.
Common Elements in Arrays
You have three sorted arrays and you have to find the common elements present in all three arrays. This is an interview question asked by companies multiple times. Most of the interviewee gets confused seeing three arrays. Choose java or c++ to write code for this program.
Smallest Missing Number
Given a sorted array of N integers, we need to find the smallest missing number in a sorted array having unique elements in the range of 0 to M-1, where M>N. In this array question, there is no need to sort the array. You can even apply the mathematical formula to find the missing number.
Max Adjacent Sum
In the given array, you need to find maximum sum of elements such that no two elements are adjacent (consecutive). You can not add immediate neighbor numbers. This array question is again an important question which is most commonly asked in interviews. This array question can be answered in java or any other language of your choice.
Find Occurrences of Number
In the given sorted array, find the number of times X is coming where X is an integer. In this interview question, they want to see if you can answer this using concept of binary search. They may modify the question like a huge array and repeated numbers are there then how will you find the specific location of the number and the number of times that number is repeating in an array. You can write this program in java.
Write a program to rotate the given image by 90 degrees. Here the image is given in the form of a matrix in 2D array. This array interview question is very common and they want to see if you are good in reading the matrix elements and do some manipulation to its elements so that the elements will look like they have been rotated by 90 degrees. You can prefer java language to answer this question.
Distance Between Numbers
Write a program to find the minimum distance between two different numbers in the given array of integers. The given array is unsorted and which may also contain duplicates. This is again a very important question commonly asked in interviews. Here distance is the absolute difference between the indexes of 2 elements of an array.
Pair with given difference
Write a program to find all pair of elements in the given array with given difference. You have an array without duplicates and if we provide you the input then you have to list down all the elements whose difference is equal to the input. This array question is very commonly asked question in interviews. Java is the first choise these days. You can opt any other language to answer this question.
Product Array Puzzle
Write a program to construct an array where the ith element will be the product of all the elements in the given array except element at ith position. This is a very tricky question and this is frequently asked in interviews. Here interviewer is looking for O(n) time complexity solution and to achieve that you are free to use extra space. You can write the algorithm in java.
Write a program to replace every element an array with the product of next and previous elements to it. This interview question can confuse you because you will think how to store the actual elements of an array if you will replace the elements in place. This interview question is asked to check if you are capable of providing the solution in O(n) time complexity or not. Choose c++ or java to answer this question.
First Repeating Element
You have an array of numbers where various numbers are repeating. You have to find the first instance of repeating number. Write a program to find the first instance of repeating element.
Move Zeroes to End
Given an array of numbers which includes zeros too. You have to write a program to arrange all the zeros at the end of an array. Here for this question interviewer is looking for O(n) solution. You can write this program in any of your choice of programming language.
You have an array of numbers. From these numbers, you need to find those three numbers which are satisfying the Pythagorean triplets equation a2 + b2 = c2.
Maximum Average Subarray
You have an array of integers and provided the size of the subarray. You have to find the sub-array of the size given whose average is maximum. This is very commonly asked question and people are looking for linear solution O(n) for this question.
Subarray Sum Equal to X
Leaders in Array
Largest Pair Sum
Segregate 0s 1s and 2s
Consecutive Elements Check
Triplet with given Sum
Binary Search in Sorted Array
Fixed point in sorted array
Reorder Elements by Indexes
Merging two sorted arrays
Find next greater number
Reorder array using given indexes
Count of triplets with sum less than given value
Merge two sorted arrays
Subarray and Subsequence
Rearrange array maximum minimum form
Find the lost element from a duplicated array
Count minimum steps to get the given array
Maximum element in an array which is increasing and then decreasing
Minimum number of jumps to reach the end of an array
Subarray with given sum
Length of Longest Increasing Subsequence
Smallest positive number missing unsorted array
The Celebrity Problem
Sorted subsequence of size 3
Find pair with given difference
Maximum length of chain pairs
Four elements that sum to given
Maximum circular subarray sum
Count possible triangles
Longest Increasing Subsequence
Petrol Bunks Tour
Tug of War
Maximum Repeating Number
Positive Negative Arrangement
Find a Peak element
Elements More Than n/k
Max Product Subsequence
Longest Bitonic subarray in an array
Number of smaller elements on right side
Implement two stacks in an array
Maximum sum increasing subsequence
Find the two numbers with odd occurrences in an unsorted array
Largest subarray with equal number of 0's and 1's
Maximum product subarray
Replace every element with the greatest on the right side in an array
Sorting a k sorted array
Find the row with maximum number of 1's
Shuffle a given array
Iterative Implementation of quick sort
Arrange given numbers to form the biggest number
Pancake sorting Problem
Maximum Subarray Sum using Divide and Conquer
Merge Overlapping Intervals
Stock Buy Sell to Maximize Profit
Sort Elements by frequency
Print all possible combinations of r elements in a given array of size n
Monotonically increasing function
Minimum element in a sorted and rotated array
Merge k Sorted Arrays
Flip Zeroes for Consecutive 1's
Least Average Subarray
Longest span with same sum in two binary arrays
Form minimum number from given sequence of D's and I's
Number of strictly increasing subarrays
Minimum difference between any two elements in an array
Number of pairs with given sum
Make Array Palindrome
Dynamic Programming, Longest Bitonic SubSequence
These are the good collection of array questions for technical interviews. Array algorithm questions are commonly asked questions for technical interviews.
array questions in java
array questions in c++