Arrays Interview Questions
- 0of 0 votes
AnswersGiven a sorted array of n integers that has been rotated left or right by k places, give an algorithm that searches and finds an element in the array in log n time.
- Tee May 23, 2010
Example Input: 8 9 0 1 2 4 5 6 (sorted array rotated right by 2 places)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays Java - 0of 0 votes
AnswersGiven a array 123456789
- Anonymous May 20, 2010
He would you rotate it like 7891234567
Do reverse string complete and then twice revert at pivot. O(N).
I gave another O(N) soln which is tricky .. . but interviewer (hiring manager) was like ek or O(N) soln hai wahe do .. .| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Arrays - 1of 1 vote
Answerssort an array of 0,1 and 2.
- dudemi May 19, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven an array of integers, find two integers whose sum is x? He asked me to give him different approaches.
- Chummi May 11, 2010
1. Naive method using two loops. ie. O(n2).
2. Uisng sorting as a preprocessing step and binary search. ie. O(nlogn).
3. Hashing. O(n).
He also asked me the end cases that should be handled. In hashing method negative numbers cannot be handled.
The interviewer was looking for all the approaches.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven a very large array of integers, you have to find out maximum difference of any 2 elements in the array such that the larger number has got bigger index than that of smaller number.
- Baba April 08, 2010
for ex -> [2 3 10 2 4 8 1] Ans -> 8 (10 - 2)| Report Duplicate | Flag | PURGE
Software Engineer / Developer Arrays - 0of 0 votes
AnswersYou have a string which stores a number with commas. For example, a string that has the number 345,000,000. How will you manipulate this string in-place [without using any extra memory] so that the output is the original string without any commas in O(n) ?
- Bandicoot April 02, 2010| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Algorithm Arrays C Coding String Manipulation - 0of 0 votes
AnswersYou are given an array which consist of number between 0 to 5 digit range. Write a function which will return true or false, if array can be divided into 2 half such a that sum of the two half would be equal
- sachin323 March 28, 2010| Report Duplicate | Flag | PURGE
FlexTrade Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven an array, find elements whos sum is 'S'.
- dnivra March 25, 2010| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer Arrays - 1of 1 vote
AnswersWhat is an array? what is a linked list? when would you use an array and linked list?
- Chummi March 23, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersPrint the longest sequence of numbers that appear in ascending order in an array(need not be contiguous). Suppose your array has values a={8,6,5,1,9,3,7,4,2,10}, the output would be 1,3,4,10.
- Anonymous March 22, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays Coding - 1of 1 vote
AnswersCan you have dynamic arrays? If yes, how do you implement it. When I mentioned about creating a larger array and copy all elements to it, he was curious to know what would be the size of this larger array.
- kanurukh March 19, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersHow would you add an element in the middle of the array...
- Anonymus March 05, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
Answersreturn the common string from 2 strings of arrays in optimal running time.
- Anonymous February 26, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
Answersfind maximum number in an Array of elements
- Anonymus February 20, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersConsider an array of positive and negative integers. We want to
- Rocky February 07, 2010
find a slice of this array (i.e. a sub‐array of consecutive elements) with at least two
elements, such that the sum of the elements in this slice is equal to 0. The size of the
slice can be anything (i.e. from 2 up to the length of the original array), and we don't
care about finding the first, last, shortest, or longest slice, we just want a slice.
Example: from [2,3,-1,2,-4] we would like to find the slice [3,-1,2,-4], where 3 + (-1) + 2 + (‐4) = 0| Report Duplicate | Flag | PURGE
Arrays - 1of 1 vote
AnswersAn array of integer of size N, all the elements are from range[1,N-1], one is duplicate, find it.
- myanything February 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersAn array of integer of size N-1, all the elements are from range[1,N], one is missing, find it.
- myanything February 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersAn array of integers, only one integer appears odd times, all others appear even times, find it
- myanything February 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven an array of integer and a target number. please find out two number that add up to the target.
- myanything February 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersWrite code to find the duplicates in an array
- Emma January 18, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays - 1of 1 vote
AnswersAssume you have two sorted integer arrays. How can you find the intersect of these two arrays? (Hint by asking question: assume that these two arrays can contain duplicated integers, and they do not have the same length) What is the time complexity? Write a function to implement it as follows:
- 6bw196 January 15, 2010void intersect(int *a, int *b, int la, int lb)
| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven an array of n numbers in which all the members are less than or equal to k (k<n). device an algorithm of order O(k) to find the first repeating element.
- Ramesh January 14, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Brain Teasers Data Structures Ideas Math & Computation Sorting - 1of 1 vote
AnswersWrite code to compare two arrays if they contain the same elements
- AM January 13, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays - 1of 1 vote
Answersa monochromatic screen is represented using single dimentional array. write a code to turn (x,y) pixel on.
- Anonymous January 02, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
Answerswrite a program to shuffle an pack of cards in the most efficient way.
- mahi December 23, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays