Arrays Interview Questions
- 0of 0 votes
Answerssearch a number in a sorted array of the form
- rahul July 17, 2011
eg: 4 5 6 1 2 3
in O(logn).| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven an infinite sorted array containings only 0 and 1 . Find the point where 0 to 1 transition happening....
- the_new_guy July 02, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersYou are given a 1D array of integers, such as:
- Jara June 22, 2011
int[] array = [3,4,7,2,2,6,0,9];
Suppose you need to treat this array as a 2D table with a given number of rows.
You want to sum the columns of the table.
One value of numRows is 4..in that case the resultant array would look like
what if numRows==4?
3 4
7 2
2 6
0 9
—-
12 21| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays - 0of 0 votes
Answersgiven an array of integers S[], visualize it as a bar graph, with the index i as x coordinate and the S[i] as the y coordinate. and that the bars are shaded. find the largest rectangle, in the shaded bars.
- Apritha May 25, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
Answersgiven two arrays A and B.
- Apritha May 25, 2011
A has integers unsorted.
B has the same length as A and its values are in the set {-1,0,1}
you have to return an array C with the following processing on A.
if B[i] has 0 then C[i] must have A[i]
if B[i] has -1 then A[i] must be in C within the sub array C[0] - C[i-1] ie. left subarray
if B[i] has 1 then A[i] must be in C within the sub array C[i+1] - C[length(A)] ie right subarray.
if no such solution exists then printf("no solution");| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersWrite a java code to find the second minimum element in an array using single loop.
- kumarasvn May 22, 2011| Report Duplicate | Flag | PURGE
Zycus Software Engineer / Developer Arrays - 0of 0 votes
AnswersIdentify the duplicates from a given array and remove them efficiently
- kumarasvn May 22, 2011| Report Duplicate | Flag | PURGE
Pega Software Engineer / Developer Arrays - -1of 1 vote
AnswersGiven a unsorted array, there is one element where a[i]==i . find the element in logn
- joman May 16, 2011| Report Duplicate | Flag | PURGE
Huawei Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven An unsorted Array of non-negative integers
- Ankit May 13, 2011
1. how many different Binary Tree can be made from this array ??
2. How Many will be unique ??
3. write an algorithm & then code to from
binary tree from this array for explanation reason & reducing the time u can take take the n=4 etc.
This is toughest question i face form amazon i stuck for moment then i explained him too much but didn't seems to be satisfied..
it was asked in problem solving & coding round so we have to write the code after explanation ??
let me know guys how u will do it..??| Report Duplicate | Flag | PURGE
Amazon Sabre Holdings Software Engineer / Developer Algorithm Arrays - 1of 1 vote
AnswersGiven an array of ints, is it possible to divide the ints into two groups, so that the sums of the two groups are the same. Every int must be in one group or the other. Write a recursive helper method that takes whatever arguments you like, and make the initial call to your recursive helper from splitArray(). (No loops needed.)
- Anonymous May 02, 2011
splitArray({2, 2}) → true
splitArray({2, 3}) → false
splitArray({5, 2, 3}) → true| Report Duplicate | Flag | PURGE
Apple Arrays - 0of 0 votes
AnswersWrite an algorithm to check if an array holds a string value that you are passing in
- ckeerthy April 28, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Algorithm Arrays Coding - 0of 0 votes
AnswersA MxN matrix is given. All rows and columns are sorted in ascending order. Search for a given number in this matrix efficiently.
- Nikhil April 28, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays - 0of 0 votes
Answersrotate a matrix by 180 degrees. mxn matrix
- Abhi April 15, 2011| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer Arrays - 0of 0 votes
Answersa number is given as an array, 4567 is given as [4, 5, 6, 7] add 1 to this number and return.
- troy April 08, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space].
- DInesh April 07, 2011
e.g. If input array is [1,3,6,8,-5,-2,3,8] It should be converted to: [-5,-2,1,3,3,6,8,8]| Report Duplicate | Flag | PURGE
Amdocs Testing / Quality Assurance Algorithm Arrays - 1of 1 vote
AnswersAn array of size n+1 has integers only from 1 to n. The integers 1 to n can be present 0 or more times in the array. Find the first repeating element in the array.
- AL March 27, 2011
Restrictions: O(n) algo required. Cannot use extra space(not even O(1)).| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays - 0of 0 votes
AnswersWe have two sorted array. Without using additional memory we need to merge these two arrays(second array is having more space for merging). Output should return through second array
- N.M March 17, 2011
I have gone through Mergesort from back to front and final data will be generated at the end of the second array.
This case second array or resultant array may have some empty spaces in the front. How to cleanup the empty spaces without using additional memory. That is additional question on the same algorithm| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersMerge two unsorted array and remove the duplicate from the resultant array.
- N.M. March 16, 2011
eg) Array1 = {"are","you","there"}
Array2={"how","are","you"}
output={"how","are","you","there"}
Can you guide me how to solve this problem efficiently.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven array of integers , return an index such that it devides the array in 2 parts ,i.e.sum of all elements which are left side of the index = sum of all elements which are right side of the index. Do in linear time.
- Anonymous March 15, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays - 0of 0 votes
AnswersPrint a 2D array spirally.
- Anil February 22, 2011| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays - 1of 1 vote
AnswersGiven an integer array, sort the integer array such that the concatenated integer of the result array is max. e.g. [4, 94, 9, 14, 1] will be sorted to [9,94,4,14,1] where the result integer is 9944141
- Anonymous February 18, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersGiven an array of characters (not sorted), how do you find the most frequent character?
- Jam February 10, 2011
Example:
{a b a c d} - Answer 'a'
{a b a b d} - Either 'a' or 'b' should work
{a b c d e} - Any character in the array| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays