Arrays Interview Questions
- 0of 0 votes
AnswersGiven an array of integers, find the mode and the frequency of the mode. If possible, print each number along with its frequency.
- msito October 25, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Arrays Java - 0of 0 votes
AnswersYou have an array of size n with values ranging from 1 to n. Exactly one number is missed and one number is repeated. Find missing number and Repeated number.
- nprabhanjan October 22, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
Answers
- veeru October 10, 2012 in IndiaFind the subsequences whose elements should not be adjacent and their sum should be maximum from the given array (contains only positive integers). Eg: int[] A = {10, 1, 3, 25} Sol: Sum: {10, 3} = 13 {1,25} = 26 {10,25} = 35 Here the Maximum subsequence is {10, 25}.
| Report Duplicate | Flag | PURGE
Myntra Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven an unsorted array.
- Shobhit October 07, 2012 in United States
With each number, we can associated a sum which is equal to the sum of all the numbers, less than the current number.
We've to find the total sum of all those numbers.
e.g. unsorted array :1, 5, 3, 6, 4.
for a[0]=1, sum[0]=0
for a[1]=5, sum[1]=1
for a[2]=3, sum[2]=1
for a[3]=6, sum[3]=1+5+3
for a[4]=4, sum[4]=1+3
total sum =sum[0]+sum[1]+sum[2]+sum[3]+sum[4] = 15| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - -2of 2 votes
AnswersGiven a sorted but rotated array. Search an element inside it without finding the pivot. Complexity of the solution should still remain O(Log n)
- Nitin Gupta October 05, 2012 in India| Report Duplicate | Flag | PURGE
Adobe MTS Algorithm Arrays Data Structures - -1of 1 vote
AnswersGiven a sorted but rotated array. Find the pivot.
- Nitin Gupta October 05, 2012 in India| Report Duplicate | Flag | PURGE
Adobe MTS Algorithm Arrays Data Structures - 0of 0 votes
AnswersGiven a list L of integers, a1 , a2 , . . . , an , and an integer M , describe an algorithm that finds the largest
- svKris October 02, 2012 in India
subset of L whose sum is at most M . Your algorithm should run in linear time| Report Duplicate | Flag | PURGE
Infosys Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersGiven an array. Find the number of inversions (if ith element is greater than jth element where i<j)
- veeru September 25, 2012 in United States
Eg: arr = {3,5,7,2,8}
Output: 3 ( 3>5, 5>2, 7>2)| Report Duplicate | Flag | PURGE
Ivycomptech Software Engineer / Developer Arrays - 0of 0 votes
AnswersJust got out of my interview realizing how ridiculously stupid I answered this question. The question was there is an array of positive and negative integers. Write an algorithm to find the subsequence with largest sum of integers in this array. Also, I can not return the entire array, even if it makes the largest sum. If the largest sum is less than -1, throw an exception.
- sameer.doha September 07, 2012 in United States
I made the mistake of ignoring negative numbers, thinking it would decrease my sum. :(| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersGiven an array of integers. Print a pair whose sum is closest to zero?
- veeru September 07, 2012 in India for Kindle Device
Eg:
Input: arr = {2 5 8 -7 2,9}
Output: => 8, -7| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven an array of intergers. Write a program to print all the permutations of the numbers in the array. The output should be sorted in a non-increasing order. For example for the array { 12, 4, 66, 8, 9}, the output should be:
- Nidhi Jain September 02, 2012 in United States
9866412
9866124
9846612
....
....
1246689| Report Duplicate | Flag | PURGE
Google Arrays - 1of 1 vote
AnswersGiven a 2D matrix of characters we have to check whether the given word exist in it or not.
- hk588853 August 30, 2012 in India
eg
bool function(char[][],char[])
s f t
d a h
r y o
we can find "rat in it
(top down , straight ,diagonal).. even in reverse order. with least complexiety.| Report Duplicate | Flag | PURGE
NVIDIA Arrays - 0of 0 votes
AnswersIf an array is having integers/Char/special Char... Ex: "PST456DA85M2A!!23++46", find out the sum of integers. ****Note: If we find consecutive digits in array we need to treat it as number, let say 456, we need to treat it as [ four hundread and fifty six]. Write a program to get the output by summing 456+85+2+23+46..also this needs to be done in lessnumber of iterations..
- Unknown August 29, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays - 0of 0 votes
AnswersGiven 2 strings - abcdefgh & cde - get the position from where the second string starts in the first string.(Do this inplace)
- sam August 28, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven an array with positive, negative and zeros, arrange the given array such that negatives are on left, zeros in the middle and positives on the right.
- babbupandey August 20, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm Arrays - 1of 1 vote
AnswersYou have 2 sorted Arrays. A and B. A is shorter than B. B has few elements in sorted order and has space for all elements of A. Now Merge these both array so that All elements are sorted. You cant use extra Array. Use Only Array B.
- Andy2000 August 16, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Arrays - 0of 0 votes
Answersu have an array of n integers. rotate it left by k positions. time complexity linear.
- Koustubh August 10, 2012 in India
without using extra array.| Report Duplicate | Flag | PURGE
Akamai Software Engineer / Developer Arrays - 0of 0 votes
AnswersCreate the n-ary tree from the ancestor matrix.
- grave July 19, 2012 in India
matrix[i][j]=1 if i is the ancestor of j.
My answer-
find the root (row with all zeroes).
Set the column with a[i][root] =0
find all the rows with all zeroes.insert into the tree all the children.and push all into the queue.
pop and find the children ,insert into the tree with popped node as parent and push into the queue.
Can not implement properly as it needed some modifications.
This is asked from my friend at amazon bangalore.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays Data Structures Trees and Graphs - 0of 0 votes
AnswersWrite a program
- ravgvn July 17, 2012 in India
Given an array of N integers . Find the maxproduct of 3 numbers ?| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays - 0of 0 votes
Answersfind a number a matrix a[m][n] where all the rows and columns are sorted non-decreasingly.What will be the complexity of the solution.
- softy July 15, 2012 in India| Report Duplicate | Flag | PURGE
Mentor Graphics MTS Algorithm Arrays - 0of 0 votes
Answersfind the balance index of an array where balanced index i is defined as the one whose left sum is equal to the right sum of the index .
- softy July 15, 2012 in India for bing
i.e
summation (1 to i-1) = summation (i+1 to length of an array) firdt I gave o(n2) solution , but then before i could give O(n) solution it was time up for me,
O(n) solution will be we have to loop through i = 1 to N and find if ( sum of array - sum of array (1 to i-1 ) = ( sum of array - sum of array (1 to i+1 ) the return i.
Your thoughts?| Report Duplicate | Flag | PURGE
Microsoft Algorithm Arrays Coding Data Structures - 1of 1 vote
AnswersImplement the plusplus operator when we are getting the input as integer array = { 9,9,9,9 }.output will be {1,0,0,0,0}
- JobHunter July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays C Coding Data Structures - 0of 0 votes
AnswersHow can you copy the contents of an array A to contents of Array B without using loops and any standard string copy functions
- TeachLead July 07, 2012 in United States| Report Duplicate | Flag | PURGE
Cubic Transportation Systems Limited Technical Support Engineer Arrays - 0of 0 votes
Answers1.sort array {0,1,1,0,1,0,1,0,0,1,1,1,0} of binary numbers in O(n) time complexity using property of binary numbers.(no counting here)
- sujita July 06, 2012 in India for GGN| Report Duplicate | Flag | PURGE
Oracle Labs247 Quality Assurance Engineer Site Reliability Engineer Arrays - 0of 0 votes
Answersint[] array = {3,-1,-2,2,2,3,2,-6,2,3,-8,0,2}; out put needed : {3,2,2,3,2,2,3,0,2,-1,-2,-6,-8} order is maintained and -ve numbers are sent to rightmost in order.
Design a code with single iteration to do it.
- sujita July 03, 2012 in United States for I| Report Duplicate | Flag | PURGE
Infosys Site Reliability Engineer Arrays - 0of 0 votes
Answersgiven 3 arrays, array a, array b, array c.
- sb June 28, 2012 in India
find all pairs where a[i] + b[j] = c[k]
a, b , c are sorted.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersIs there any alternative in c++/c to pass array to a function by value apart from cloning so that no change is reflected?
- codez June 25, 2012 in United States| Report Duplicate | Flag | PURGE
Arrays - 0of 0 votes
AnswersFind the nth most frequent number in array
- mdfirozansari June 09, 2012 in India for MP3 mobile team| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - 0of 0 votes
AnswersGiven two arrays a1={1,2,3,4} and a2={5,6,7,8}, add the two array and return a new array n={6,9,1,2}
- sathish.leo May 26, 2012 in United States| Report Duplicate | Flag | PURGE
Expedia Software Engineer / Developer Arrays