## Arrays Interview Questions

- 0of 0 votes

Answersgiven 2 Dimensional array

- xyz January 30, 2014 in United States

I/P -- String[][] input = { { "abc", "def", "gh" },

{ "f", "g" },

{ "qrt","xyz","pqr" } };

Program shd return a 2-D Array with

O/P -- { { "abcfqrt", "abcfxyz", "abcfpqr" ,abcgqrt and so on ..| Report Duplicate | Flag | PURGE

Google SDE-2 Arrays - 1of 1 vote

AnswersGiven a 3-D array, if any m[r][c][d] is <=0 mark all the cells in the entire row,col and depth as zero and return the o/p array

- juny January 22, 2014 in United States for Traffic| Report Duplicate | Flag | PURGE

Ebay SDE-2 Arrays - 0of 0 votes

Answers

- aryan January 17, 2014 in United States`suppose u r given a 4*3 rectangle like (take these values from user)Now u have to calculate the no. of squares in this rectangle like:No. of squares of dimension 1 is 12No. of squares of dimension 2 is 6No. of squares of dimension 3 is 2No. of squares of dimension 4 is 0Total no. of squares are 2`

| Report Duplicate | Flag | PURGE

Arrays - 0of 0 votes

Answerssuppose u r given a 4*3 rectangle like (take these values from user)Now u have to calculate the no. of squares in this rectangle like:No. of squares of dimension 1 is 12No. of squares of dimension 2 is 6No. of squares of dimension 3 is 2No. of squares of dimension 4 is 0Total no. of squares are 2

- aryan January 17, 2014 in United States| Report Duplicate | Flag | PURGE

Arrays - 1of 1 vote

Answers

- Srigopal Chitrapu January 15, 2014 in United States`In given array find zero and replace the entire row and column with zeros E.g Input: 1 2 3 4 5 6 7 8 9 10 0 11 12 13 14 15 Output: 1 2 0 4 5 6 0 8 0 0 0 0 12 13 0 15`

| Report Duplicate | Flag | PURGE

Microsoft SDE-2 Arrays Coding Matrix - 0of 0 votes

AnswersHow to find the adjacent elements of an single dimensional array whose difference is 1; What is the Time Complexity & Auxiliary Space you use ? What type of efficiency can be achieved?

- soul January 08, 2014 in India for Chennai| Report Duplicate | Flag | PURGE

Amazon Software Engineer in Test Arrays - 0of 0 votes

AnswersHow to sort an single dimensional array whose elements are {4,5,6,4,5,6}; What is the Time Complexity & Auxiliary Space you use ? What type of efficiency can be achieved?

- soul January 08, 2014 in India for Chennai| Report Duplicate | Flag | PURGE

Amazon Software Engineer in Test Arrays - 2of 4 votes

AnswersGiven a sorted array of integers, write a function that will return the number with the biggest number of repetitions.

- GeorgyBoy December 30, 2013 in Israel

(Asked to refine the solution to be more efficient)| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer Algorithm Arrays Coding Data Structures Problem Solving Sorting - 0of 0 votes

AnswersUsing the following function signature, write a C# function that prints out every combination of indices using Console.WriteLine() whose values add up to a specified sum, n. Values of 0 should be ignored.

- koshinski December 16, 2013 in United States for XBOX

public void PrintSumCombinations(List<int> numbers, int n);

• It’s okay to use additional private functions to implement the public function

• Be sure to print out the indices of numbers and not the values at those indices

• Don’t worry too much about memory or CPU optimization; focus on correctness

To help clarify the problem, calling the function with the following input:

List<int> numbers = new List<int> { 1, 1, 2, 2, 4 };

PrintSumCombinations(numbers, 4);

Should result in the following console output (the ordering of the different lines isn’t important and may vary by implementation):

0 1 2 (i.e. numbers[0] + numbers[1] + numbers[2] = 1 + 1 + 2 = 4)

0 1 3

2 3

4| Report Duplicate | Flag | PURGE

Megasoft Software Engineer in Test Algorithm Arrays - 1of 1 vote

AnswersGiven a sorted array with duplicates, move the distinct elements to the top

- juny December 12, 2013 in United States for Traffic

Ex: 1,1,2,3,4,4,5 -> 1,2,3,4,5| Report Duplicate | Flag | PURGE

Ebay SDE-2 Arrays - -2of 2 votes

AnswersGiven an array with numbers, your task is to find 4 numbers that will satisfy this equation:

- Alexandru Mihai December 11, 2013 in United States

A + B + C = D| Report Duplicate | Flag | PURGE

Twitter Software Engineer Intern Arrays - 0of 0 votes

AnswersFind the maximum-sum subarray of an array.

- floatingsms November 29, 2013 in United States| Report Duplicate | Flag | PURGE

Microsoft Software Engineer Intern Arrays - 0of 0 votes

AnswersGiven an array which has prime numbers, find all duplicates elements of array.

- OTR November 23, 2013 in India| Report Duplicate | Flag | PURGE

iLabs Tech Lead Algorithm Arrays - -3of 3 votes

AnswersArray Pair Sum. Solve it in O(N) time complexity

- shreya November 20, 2013 in United States| Report Duplicate | Flag | PURGE

Cloudera Software Engineer / Developer Arrays - 4of 6 votes

AnswersArrange the numbers in an array in alternating order.

- codefreak November 16, 2013 in United States

For example if the array is [a1, a2, a3, a4.. ]arrange the array such that b1<=b2>=b3<=b4 and so on.

Sampe Input: 3 5 7 8 4 9

Sample Output: 3 < 5 > 4 < 8 >7 < 9| Report Duplicate | Flag | PURGE

Microsoft Software Engineer / Developer Arrays - 4of 4 votes

AnswersGiven an integer array. Perform circular right shift by n.

- wolfengineer November 09, 2013 in United States

Give the best solution.| Report Duplicate | Flag | PURGE

Microsoft Software Engineer / Developer Arrays - 1of 1 vote

AnswersGiven an array, remove the duplicates and return a unique array keeping the first occurrence of the duplicates and the order.

- kchronis October 29, 2013 in United States for iOS

[@2, @1, @3, @1, @2] --> [@2, @1, @3]| Report Duplicate | Flag | PURGE

Facebook iOS Developer Arrays - 0of 0 votes

AnswersWrite a method in Java to reverse an array in chunks of 3. You should also consider cases where an array is not a multiple of 3.

- PinkTulips October 25, 2013 in Canada

For example:

Input array: {1,9,6,4,5,8,3,1,5}

Expected results:{6,9,1,8,5,4,5,1,3}| Report Duplicate | Flag | PURGE

Arrays - 2of 2 votes

AnswersGiven an n x n matrix A(i,j) of integers, find maximum value A(c,d) - A(a,b) over all choices of indexes such that both c > a and d > b.

- vik October 07, 2013 in United States

Required complexity: O(n^2)| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm Arrays Data Structures Ideas Matrix - 1of 1 vote

AnswersWrite a function to generate a second array of numbers containing running average of N elements from the original array

- vik October 04, 2013 in United States

So for instance if the original array is,

2,6,4,2,3 and N=3

result = 2,4,3,4,3

you can assume the corner elements can be filled with original elements where there are not enough elements to take avg of N elements| Report Duplicate | Flag | PURGE

NVIDIA Software Engineer / Developer Algorithm Arrays - 0of 0 votes

AnswersThere is an array with an input {0,1,2,3,5,6,9} . Write a program to show the combinations for which the sum is 9.

- freaks September 22, 2013 in India

Ex - {3,6} , {0,9} ... etc| Report Duplicate | Flag | PURGE

Quality Assurance Engineer Arrays - 0of 0 votes

AnswersGiven an array with huge number of elements. Following two operations can be performed on the array at any time

- Anonymous September 18, 2013 in India

1. Find cumulative sum of first x numbers when x is input by user

2. Add/subtract value 't' from any index i of the array.

Find the most optimal way such that both the above requirements are optimized.| Report Duplicate | Flag | PURGE

Flipkart Arrays - 0of 0 votes

AnswersGiven a 2d matrix with characters and a dictionary. Find non-distinct occurrences of the words found in the array, horizontally, vertically or diagonally, and also the reverse in each direction.

- Rinka September 11, 2013 in United States| Report Duplicate | Flag | PURGE

Software Engineer / Developer Arrays - 6of 6 votes

AnswersGiven an input array

- gowthamganguri August 30, 2013 in India

a={1,2,3,6,2,8----}

product of all numbers=p=a[0]*a[1]*---a[n-1] where n is size of array

output arrau should be b={p/a[0],p/a[1],p/a[2]-----}. you should not use division operator.Time complexity should be less than o(n2).| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Arrays - 4of 4 votes

AnswersGiven a array of size n. Divide the array in to two arrays of size n/2,n/2. such that average of two arrays is equal.

- gowthamganguri August 29, 2013 in India| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Arrays - -2of 2 votes

AnswersIn the given sorted array, find the number of positions of the number that are not in sorted order

- saran August 24, 2013 in India| Report Duplicate | Flag | PURGE

Chronus Intern Arrays - 0of 2 votes

AnswersThere is an sorted array suppose 10 20 30 40 50 60 70 80 90. If we rotate it n times(suppose n = 3 in my case). The array will be 70 80 90 10 20 30 40 50 60. The total no of values which are not in right position 3(in this case which are 70 80 90) so we have to make a generalized solution. I was able to answer this in O(n) but he wants something which is lesser than O(n).

- tarunverma August 23, 2013 in India| Report Duplicate | Flag | PURGE

Akamai Java Developer Arrays - 0of 0 votes

AnswersI have an array containing duplicates in the following format:

arr[]={ 2,9,1,5,1,4,9,7,2,1,4 }

I want to sort the array in place such that all the duplicate elements are moved towards the end and sorted in different sub arrays like following:

arr[]={ 1,2,4,5,7,9, 1,2,4,9, 1 }

There is no range for integers for the array specified. Following is the code which i tried. This code recursively sorts the subarrays and then move duplicates towards the end. But Complexity wise this is not optimal solution.

Please suggest if it can be solve in O(n) or O(nlogn). Entire code is as follows:

- ronansaini August 15, 2013 in India`public static int sortDuplicates(int a[],int start,int end){ int i, k,temp; if(start==end) return 1; Arrays.sort(a, start, end); k = start; for (i = start+1; i < end; i++) { if (a[k] != a[i] && a[k]<a[i]) { temp=a[k+1]; a[k+1] = a[i]; a[i]=temp; k++; } } return sortDuplicates(a,k+1,a.length); }`

| Report Duplicate | Flag | PURGE

United HealthGroup Java Developer Algorithm Arrays - 0of 0 votes

AnswersGiven an array, return true, if it can be partitioned into two subarrays whose sum of elements are same, else return false

- saran August 13, 2013 in India

Example:

Input: {5,1,5,11}

Output: true (as it can be divided into {5,1,5} {11} where 5+1+5=11)| Report Duplicate | Flag | PURGE

Groupon Intern Arrays

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.