Arrays Interview Questions
- 4of 4 votes
AnswersIf [a1,a2,a3...,an,b1,b2...bn] is given input change this to [a1,b1,a2,b2.....an,bn] , solution should be in-place
- Anonymous February 05, 2011| Report Duplicate | Flag | PURGE
Amazon Microsoft Developer Program Engineer Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersFind the output of the following Program-
- ajitpec January 22, 2011
void main()
{
int array[4]={10,20,30,40};
int *tmp=array;
for (int i=0;i<4;i++)
{
tmp+=sizeof(int);
printf("%d",*tmp);
}
getch();
}
i think it should be 30 0 0 0| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Arrays - 0of 0 votes
AnswersI was asked this at a career fair by one of the recruiters and I think I gave a pretty bad answer for it (although the recruiter said he was happy with it). The question was having an integer array where there are repeating numbers and all but one repeat an even number of times. How would you find the number that repeats an odd number of times? He also asked if this can be done without using other data structures. (I think he said the array wasn't sorted).
- JayNeedsAJob January 15, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersFind two elements in an array whose sum is closest to zero??
- Anonymous December 22, 2010| Report Duplicate | Flag | PURGE
Arrays - 0of 0 votes
AnswersInput: Array of integers, A[0], A[1], ..., A[n]
- hobocs December 07, 2010
An operation is defined to have all A[i] altered by 1, i.e., A[i]++/A[i]--. Note whether A[i] is increased or decreased is independent from other elements in A.
Question: return the minimum number of operations to make all elements in A[i] be equal. If it is impossible, return -1;| Report Duplicate | Flag | PURGE
Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven an array containing lower case and upper case alphabets and numbers, how can you sort/arrange the array in one single pass using just one variable for swapping such that the resultant array should put the input elements into 3 buckets in the following fashion -
- YT2010 November 18, 2010
Input - aA1B23Cbc4
Output - abcABC1234
Note - ordering doesn't matter
the output could be -
ABC1234abc or 1234abcABC
You just have to arrange the data into 3 buckets in single pass using just one temp variable for swapping. Expected runtime - o(n)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Arrays - 0of 0 votes
AnswersWrite a program to remove duplicate elements from array.(Array contains elements in range 1...N). Algorithm must be O(N) in time and O(1) in space. Come up with as many test cases as you can.
- omkar November 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven a sorted integer array (e.g. 1 2 3 4 5). It is shifted by k pos to right (e.g. for k=2 and the new array is (4 5 1 2 3). Find what's the value of k based on the new array.
- Cartman October 19, 2010
Hint: O(n) solutions is obvious. Can you do better? say O(lg n).| Report Duplicate | Flag | PURGE
Software Engineer / Developer Arrays - 0of 0 votes
AnswersQ. There is an array
- Anonymous August 29, 2010
A[N][M] =
1 2 3
4 5 6
The array is rotated so that
A'[M][N] =
3 6
2 5
1 4
is obtained.
Establish the relation between A and A' by using i, j, M, N
A[i][j] = A'[_][_]| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersThere is an array consisting of postive and negative integers. find the subarray whose sum is 0
- Anonymous August 23, 2010| Report Duplicate | Flag | PURGE
Arrays - 1of 1 vote
AnswersGiven an array of 0s and 1s , in O(n) time and inplace,make all the 0s in one side and all the 1s in other.
- Anonymous August 23, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersWrite an algorithm to find the absolute max subsequence of an array containing both positive and negative numbers in O(n) time
- Yashanth August 19, 2010
Eg: {100,-2,300} sum=398
{1,2,3,-9} sum=9
{1,2,3,-4} sum=6
{-1,-2} sum=3| Report Duplicate | Flag | PURGE
Deshaw Inc Software Engineer / Developer Arrays - -1of 1 vote
AnswersIn a single linked list, how to delete a node (no head node given).
- abcd August 13, 2010| Report Duplicate | Flag | PURGE
EMC Software Engineer / Developer Arrays - 0of 0 votes
AnswersFind repeated number in a sorted array
- abcd August 13, 2010| Report Duplicate | Flag | PURGE
EMC Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven an array A, find A' where every element of A' is product of remaining elements of A.
- AmazonPersonalRound July 30, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersProvided a array of size 100 stuffed with ONLY 99 values from 1 to 100 ,SO array size is 99 now .
- Ganesh Gowtham July 11, 2010
How can you find the 100th value in that array ?
Answer is Mathamtic Progession .
Add 1 to 100 Lets say X
add 99 elements in array Lets say Y
X - Y is our answer .| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer Arrays - 0of 0 votes
AnswersWrite a Code to merge N sorted array.
- MaYanK July 08, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersWrite an algorithm to find the duplicates in two unsorted arrays
- someone June 28, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersStock prices are given to you at various time intervals. p1, p2, p3,... you are allowed to buy and sell only once each. So write a program to find the index where you would buy and where you would sell to maximize profit
- someone June 28, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersYou are given a sorted array that is rotated circularly from a particular point. for example 12345 rotated about 3, circularly is 34512
- someone June 28, 2010
you have to search for a number in that list
in O(lgn)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersThere is very long array of ints, and you are given pointer to base addr of this array.. each int is 16bit representation... you need to return the pointer to tht "bit" inside array where longest sequence of "1"s start
- gradStudent June 16, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays Bit Manipulation Computer Architecture & Low Level - 1of 1 vote
AnswerDifferentiate between arraylist in java and linked list.
- Guest May 30, 2010
Complexities for searching and insertion.| Report Duplicate | Flag | PURGE
Arrays - 0of 0 votes
AnswersGiven two arrays A [n] and B[m], find the smallest window in A that contains all the elements of B.
- binu May 28, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays - 2of 2 votes
AnswersAn array of integers of size n-1, all the elements are form [1,n]. Find the missing number. You can read only one bit in one operation, ie, to read A[i], you need to perform log(A[i]) operations.
- binu May 28, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays Bit Manipulation - 1of 1 vote
AnswersFind median of two sorted arrays.
- binu May 28, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays