# Arrays Interview Questions

Hello, people..! In this post, I will discuss some of the arrays interview questions (coding and conceptual), which you must solve before you attempt any technical interviews. The questions are given below. You may click on the question to see its solution. But, it is extremely recommended to think about how you would give your approach to solve a particular question before looking at its solution. And if you are reading this post, I assume that you have pretty good amount of experience with algorithms.. 😛

### Coding Questions

Find the missing number in an array which has numbers from 1 to N, but with one number missing.
Find the element in an array which is occurs only once while all the other elements occur twice.
Intersection of two sorted arrays.
Find the top K numbers in an integer array of size N.
Given a 2D array, print it in spiral form.
Find the first occurrence of an element in a sorted array which contains duplicate elements.
Find the last occurrence of an element in a sorted array which contains duplicate elements.
Find any one peak element in an unsorted 1-D Array.
Find the number of times the array is rotated, the pivot element in the sorted and rotated array.
Search for an element in a sorted and rotated array.
Sum of 2 numbers which are equal to a given value.
Sum of 3 numbers which are equal to a given value.
Sum of 4 numbers which are equal to a given value.
Find the kth smallest/largest element in an array.
Find the majority element in the array
Find the maximum contiguous sum of an array.

This post is a little dynamic. More questions will be added as soon as the solutions are made, some of the questions which will come in the near future are –

• Median of two sorted arrays.
• Find the smallest positive integer that cannot be represented as the sum of any subset of the array.
• Find the number of duplicates in an array using O(1) space.
• Given an array with +ve and -ve numbers. Rearrange such that +ve and -ve numbers appear alternatively, maintaining the relative order, using O(1) space.

### Conceptual Questions

Difference between an array and a linked list.
Why does it take constant time for accessing array elements?
What is the difference between int[] arr, and int arr[] in Java?
From where is the memory allocated for arrays in Java?
In C, what is actually passed when you pass an array to a function?
What are the strategies involved in growing the size of arrays in the case of dynamic growing arrays?
How can you pass a 2D array to a function in C ?

I hope these questions help you. These are pretty base level interview questions. Nothing too great. But if you can solve these it will give you a great confidence boost and, what’s more, is that you can use these techniques to solve bigger problems based on arrays. Do leave a comment if you liked my post or if you have any queries… 🙂 … Keep practising… Happy Coding.. 😀