Arrays Interview Questions
- 2of 2 votes
AnswersFind the majority element which occurs more than n/2 times in an array of n size, which contains duplicate elements in minimum time and space complexity.
- saran August 07, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Arrays - 0of 0 votes
AnswersTwo arrays are given. Data from both the arrays have to be taken and put into the third array and this third array should have only unique elements. Implement this without using set.
- Ram August 06, 2013 in India for QATeam| Report Duplicate | Flag | PURGE
VMWare Inc Quality Assurance Engineer Arrays - 0of 0 votes
AnswersGiven you an array of 100 Elements with one number missing, how will you find the missing number?
- radibioinfo July 25, 2013 in United States
Array 1 to 100 with 55 missing.| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - 0of 0 votes
AnswersMaximum value Continuous Subsequence:
- pirate July 25, 2013 in United States
Given array A[n] find continuous subsequence a[i]..a[j] for which sum of elements in the subsequence is maximum.
Ex: {-2, 11, -4, 13, -5, -2} --> 11 - 4 +13 = 20
{1, -3, 4, -2, -1, 6} --> 4 -2 -1 +6 = 7
Time complexity should O(nlogn)| Report Duplicate | Flag | PURGE
Yahoo Microsoft Linkedin Software Engineer / Developer Algorithm Arrays - 23of 23 votes
AnswersYou are given an array of n integers which can contain integers from 1 to n only . Some elements can be repeated multiple times and some other elements can be absent from the array . Write a running code on paper which takes O(1) space apart from the input array and O(n) time to print which elements are not present in the array and the count of every element which is there in the array along with the element number .
- Kavish Dwivedi July 15, 2013 in India for Bangalore
NOTE: The array isn't necessarily sorted.| Report Duplicate | Flag | PURGE
Amazon SDE1 Arrays - 0of 2 votes
Answersgiven two arrays of same size, arrange the arrays such that a1*b1 + a2*b2 + .... + an*bn should ne minimum.
- pavi.8081 July 11, 2013 in India for Fraud prevention| Report Duplicate | Flag | PURGE
Amazon SDE-2 Arrays - 3of 3 votes
AnswersIn a given array a = {1, 7, 3, 4, 5, 6, 2} Print the indices of all the combinations which lead to a given sum called target. For e.g. if the method is
- Jeanclaude July 09, 2013 in United States
Void PrintAllSumCombos(int[] arr, int target) - and the array shown above is passed with sum target = 7, then the output should be:
0, 3, 6
0, 5
1
2, 3
4, 6
Note: For simplicity, You may assume the array does not contain any negative numbers and also consider same set of indices with a different order as identical - for e.g. if 2, 3 is already printed, ignore 3, 2 as they are one and the same.| Report Duplicate | Flag | PURGE
Accenture Software Engineer in Test Arrays - 6of 12 votes
AnswersGiven a list of integers, find out the biggest interval that has all its members in the given list. e.g. given list 1, 7, 4, 6, 3, 10, 2 then answer would be [1, 4]. Develop algorithm and write code for this
- prongs July 08, 2013 in India| Report Duplicate | Flag | PURGE
Google Applications Developer Algorithm Arrays C++ Coding - 1of 7 votes
AnswersGiven an array of numbers, arrange it such that all the numbers less than a given key should come before the key and all the numbers greater than the key should come after it.
- Vasily_Zaytsev June 30, 2013 in United States
For example: arr = { 0, -1, -2, 2, 0, 3, 5}, given key = 0
answer should be {-1, -2, 0, 0, 2, 3, 5}
Order of elements that are smaller or greater than key does not matter i.e. sorting is not expected. So, {-1,-2, 0, 0, 5, 2, 3} is also a correct answer.
Time complexity should not be more than O(n).| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 2of 2 votes
AnswersIn an array of unsorted integers (you may assume the array may contain +ve, -ve and 0s), write a function
- Jeanclaude June 28, 2013 in United States
int returnNthMax(int[] arr, int n)
which will return the nth Max number. For e.g. if this is given array {2, -4, 5, 6, 0, 7, -1, 10, 9} and n=1, it should return the max number, 10 and if n=3, it should return 3rd max number, which is: 7.| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays - 0of 0 votes
Answersgiven two unordered list find the greatest common integer
- helpme June 26, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Arrays - 1of 1 vote
AnswersGiven two array of integers write two functions that will return an Union and Intersection
- JSDUDE June 13, 2013 in United States
Time efficient
Both time and space efficient implemented| Report Duplicate | Flag | PURGE
Ebay Software Engineer / Developer Arrays - 3of 3 votes
AnswersConsider an array of integers wherein each element is +1 or -1 its preceding element. Given a number, find the first occurence of this number (index) in this array without using linear search.
- nilukush June 04, 2013 in India for World Wide Operations
For example, consider the array :
4 5 6 5 6 7 8 9 10 9 10 (each element in this array is +1 or -1 its preceding element)
Input : 10 (find first occurence of 10 without using linear search)
Output : 8| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm Arrays - 0of 0 votes
AnswersMerge the given 2 input sorted arrays of numbers into one . The merged array stays sorted .
- meek May 31, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays Java Problem Solving Sorting - -5of 7 votes
Answersneed to implement a weather report functionality. user will provide the city name , need to return the weather report.
- gopi.komanduri May 29, 2013 in India
if weather station exists n functioning properly , will return the weather report of that station .
else ,
will return the nearest available weather station report.
interviewer looking for optimized manner.
looking for datastructures to stores the cities n algo to return the report.| Report Duplicate | Flag | PURGE
Mentor Graphics Analyst Algorithm Arrays Bit Manipulation Brain Teasers C C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming General Questions and Comments Graphics Hash Table Ideas Linked Lists Math & Computation Object Oriented Design Problem Solving Sets Sorting Stacks String Manipulation Terminology & Trivia Threads Trees and Graphs XML - 0of 0 votes
AnswersWrite a Method in Java which takes an Array of strings and from the array of strings returns only those strings which have a consecutive repetition of a particular letter for eg: if I/P is {"Dauresselam", "slab", "fuss", "boolean", "clap"}
- Anirudh May 28, 2013 in United States
then O/P should be {"Dauresselam", "fuss", "boolean"}| Report Duplicate | Flag | PURGE
Ibibo Testing / Quality Assurance Arrays - -3of 3 votes
AnswersYou have an array of binary numbers as "00001101000001010100000..."... We need to find the First occurrence of 1 in this series.. using binary search.
- imvrajendra May 21, 2013 in India
we need to design an algorithm of complexity less than O(n).. and we need to use binary search strictly..| Report Duplicate | Flag | PURGE
Amazon SDE1 Arrays - 8of 10 votes
AnswersEliminate all ‘b’ and ‘ac’ in an array of characters, you have to replace them in-place, and you are only allowed to iterate over the char array once.
- jeso May 18, 2013 in Switzerland
Examples:
abc -> ac
ac->''
react->rt| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays - 2of 2 votes
AnswersSort an array which only has 0's and 1's. Do not use count sort.
- CodeNameEagle May 10, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm Arrays - 1of 1 vote
AnswersGiven a string, find the longest possible even palindrome (length of palindrome is even) from it.
- arun_lisieux May 10, 2013 in India
Eg:
Input: abcicbbcdefggfed
Output: defggfed (length is 8)
Available palindromes are
1) bcicb - has odd length
2) cbbc - even length
3) defggfed - longest palindrome with even length
This question was asked in a telephonic interview for my friend. I will be posting his solution in a day.| Report Duplicate | Flag | PURGE
Groupon Software Engineer / Developer Algorithm Arrays Coding String Manipulation - 0of 0 votes
Answerswrite a program to serialize and deserialize a Binary tree
- VJ May 06, 2013 in India| Report Duplicate | Flag | PURGE
VMWare Inc Member Technical Staff Algorithm Arrays Data Structures Trees and Graphs - -14of 16 votes
AnswersFor 2 given array a[] and B[], find the highest index of A such that logical array A[0...i] and A[N-1...N-1-i] are same.
- Razz May 06, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Arrays - 1of 1 vote
AnswersGiven a rotated sorted array, find the MIN of the array.
- JSDUDE May 04, 2013 in United States
He pointed out a mistake in my
int middle = (begin+end)/2 which could overflow if the array size was INT_MAX.
Answer was:
middle = (end-begin)/2 + begin| Report Duplicate | Flag | PURGE
Microsoft SDE1 Arrays - 2of 2 votes
AnswersFind the Max sum subsequence in array
- JSDUDE May 04, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 Arrays - 0of 0 votes
AnswersYou have an array Char[] chArray = {'a','a','b','c','a','b','d','c','c','d','a','a'}
- cCAACc May 04, 2013 in United States
Write a program to remove the duplicate and the output should be as per the below:
{'a','b','c','d','','','','','','',''} . You should not use any collection api| Report Duplicate | Flag | PURGE
Barclays Capital Senior Software Development Engineer Arrays - 0of 0 votes
AnswersFor given N* N matrix,
- Sachin April 20, 2013 in India
1 2 3
8 9 4
7 6 5
Write a program to
print 1,2,3,4,5,6,7,8,9| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - -2of 2 votes
Answers//Q. Given an array of integers,write a function that retrieves unique instances of any duplicates, returning them in a //new array -
- JSDUDE April 15, 2013 in United States
// [2,1,2,4,3,1,5,1]
//= [2,1]
// [1,1,1,1,1,1,1,1,1]
// =[1]
// Write test cases for this function| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays Testing - -2of 4 votes
Answersfind a pattern in byte array and change that pattern in place (do not use temp array or variable)
for example, find pattern 0,0,3 in an byte array and replace it with 0,0
should be o(n)
my solutions :
- SDguy April 03, 2013 in United StatesByte*remPattern003(byte arr[] , int &size) //size is input and output variable ///outputs size of output array { int k = 0; for(int i=0;i<size;) { if(arr[i] == 0 && arr[i+1] == 0 && arr[i+2] == 3) { arr[k++]=arr[i]; arr[k++]=arr[i+1]; arr[k]=arr[i+3]; i+=3; } else arr[k++]=arr[i++]; } size= k; return arr; }
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Arrays - 1of 3 votes
AnswersWrite a program to find the element in an array that is repeated more than half number of times. Return -1 if no such element is found.
- Expressions March 19, 2013 in India| Report Duplicate | Flag | PURGE
Linkedin SDE1 Arrays - 0of 0 votes
AnswersDesign a Tic Tac Toe Game. Classes Segregation and Code Flow.
- hprem991 March 18, 2013 in India| Report Duplicate | Flag | PURGE
StartUp Amazon Software Architect Software Engineer / Developer Algorithm Android Application / UI Design Arrays Assembly Automata Behavioral Bit Manipulation Brain Teasers C C++ Object Oriented Design