Arrays Interview Questions
- 0of 0 votes
AnswersA matrix is "Toepliz" if each descending diagonal from left to right is constant. Given an M x N matrix write the method isToepliz to determine if a matrix is Toepliz.
- enkadi13 July 22, 2016 in United States
Example:
Input:
67892
46789
14678
01467
Output:
True| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm Arrays - 0of 0 votes
AnswersPrint the element in anti spiral order
- Siva Vishal July 03, 2016 in India
for example
Matrix
1 2 3
4 5 6
7 8 9
o/p
5 6 9 8 7 4 1 2 3| Report Duplicate | Flag | PURGE
Zoho Student Arrays - 0of 2 votes
AnswersThere are 2 arrays of integers.You have to add the those integers and keep it in 3rd array.there is one condition, if the sum is a 2 digit number, split that number into single digiit and other condition is if any of the array integer is left then print that number
- Ajay April 05, 2016 in India for amazon.in
I/P:
int[] a = {1,2,3,4,5,6}
int[] b = {2,3,4,5,6,7,8}
o/p:
{3,5,7,9,1,1,1,3,8}| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - 0of 0 votes
AnswersGiven a histogram chart with values say {5,4,3,6,0,1}. Get the total count required to completely melt the histogram. A column with value 5 has 5 blocks in it. Any block which has air on any of its side gets melted.
- abc_abc March 07, 2016 in United States
Sample 1
{5,4,3,6,0,1} - > {0,3,2,0,0,0}->{0,0,0,0,0,0} => count=2
Sample 2
{0,1,1,1,1,0} - > {0,0,0,0,0,0} => count=1| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer Arrays - 0of 0 votes
AnswersAllocate a 2-D array of size m*n using malloc(). The array should be accessible as a[i][j].
- Saurabh Singhal January 16, 2016 in India| Report Duplicate | Flag | PURGE
Arista Networks Software Engineer Arrays C Data Structures Matrix - 0of 0 votes
AnswersGiven an array of stock values of a company. Find out the time when a user would have bought the stock and sold the sock. Basically find the maximum positive difference of any two given elements in an array?
- avinash.setty December 12, 2015 in United States for Marketplace| Report Duplicate | Flag | PURGE
Amazon SDE-2 Arrays - 0of 0 votes
AnswersWe have a file path as like this:
- johnsvakel December 07, 2015 in India for DS
wchar_t* pCompletePath = L"\\?\UNC\10.1.3.23\TOKEN$\0x464564564576\C\FileDrive\Testcase.doc";
Write a C++ function which will take input argument as above string and gives output as L”\\?\UNC\10.1.3.23\TOKEN$\C\FileDrive\Testcase.doc” (Removing one token after the TOKEN$)
Constraints: TOKEN$ will be there for all strings, so we can use that for search| Report Duplicate | Flag | PURGE
Symantec Senior Software Development Engineer Arrays - 1of 1 vote
AnswersWAP in java to find duplicate element in array in one scan.
- swapbhikule83 November 29, 2015 in India| Report Duplicate | Flag | PURGE
xyz Java Developer Arrays - -1of 3 votes
Answerswrite a method that takes in 2 int arrays of any size and returns an array that calculates the sum of both.
- J@sper November 26, 2015 in United States for -
for example, [1,2,3] and [2,3,4] will return [3,5,7]
Or [1,2,3] and [2,3,5,5] will return [2,4,7,8]
however, if it's like [9,9,2] and [0,1,3] you need to carry the sum so it returns as [1,0,0,5]
** SINGLE DIGIT ONLY| Report Duplicate | Flag | PURGE
Google Intern Arrays - 0of 0 votes
AnswersGiven an array of both positive and negative integers , find all pairs whose sum is equal to zero.
- sudhiaithal October 30, 2015 in United States| Report Duplicate | Flag | PURGE
xyz Software Engineer Algorithm Arrays - 0of 0 votes
AnswersFind if the characters of the sample string is in the same order in the text string.. Give a simple algo..
- sachin.and3 October 18, 2015 in United States
Eg.. TextString: abcNjhgAhGjhfhAljhRkhgRbhjbevfhO
Sample string :NAGARRO| Report Duplicate | Flag | PURGE
Nagarro Java Developer Algorithm Arrays Brain Storming Brain Teasers Coding Hash Table String Manipulation - 0of 0 votes
Answersconsider an array1={1,1,1,1,1,1,1,1,1,1}
- sekardhana94 October 07, 2015 in India
if n=4 add first four elements and next four elements
result : array1={4,4,2}
if n=3 add first three elements and next three elements repeat process untill size of array <=n
result1:
array1={3,3,3,1}
result2 : array1={6,4}| Report Duplicate | Flag | PURGE
ss Java Developer Arrays - 0of 0 votes
AnswersGiven a string and array of strings, find whether the array contains a string with one character difference from the given string. Array may contain string of different lengths.
Ex: Given stringbanana
and array is
[bana, apple, banaba, bonanza, banamf]
and the outpost should be true as banana and banaba are one character difference.
- kpraveen420 October 03, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays String Manipulation - 1of 1 vote
AnswersInteger Array Ques:
- cdude September 01, 2015 in United States
Given an integer array of variable length like so [9, 8, 8, 3] where each item in array could be 0 to 9, write a function that would take would interpret the array [9, 8, 8, 3] as a number 9883 and increment it by 1. The return of the function would be an integer array containing the addition like so [9,8,8,4]. No zeros in the first position like [0,1,2,3]. I initially suggested a possible solution of process to convert the integer array to String then convert to Integer or Long and then do the addition of 1 and then convert it back to integer array. That is not allowed when the interviewer change the ques. to not allow that.| Report Duplicate | Flag | PURGE
Google Android Engineer Arrays - 2of 4 votes
AnswersA string contains a-z, A-Z and spaces. Sort the string so that all lower cases are at the beginning, spaces in the middle and upper cases at the end. Original order among lower and upper cases needs to remain the same. For example: a cBd LkmY becomes ackm BLY. Is there a way in O(n) without extra space?
- chad August 13, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Algorithm Arrays - 0of 0 votes
AnswersSheldon Cooper, Leonard Hofstadter and Penny decide to go for drinks at Cheese cake factory. Sheldon proposes to make a game out of this. Sheldon proposes as follows,
- a.selvaganesh10 August 11, 2015 in India
• To decide the amount of beverage they plan to consume, say X.
• Then order for a random number of different drinks, say {A, B, C, D, E, F} of quantities {a, b, c, d, e, f} respectively.
• If quantity of any three drinks add up to X then we'll have it else we'll return the order.
E.g. If a + d + f = X then True else False
Input Format:
1. First line contains number of bottles ordered denoted by N
2. Next N lines, contains a positive integer Ai, the size of the ith bottle
3. Last line contains the quantity they intend to consume denoted by X in text above
Output Format:
True, if combination is possible
False, if combination is not possible
Input:
6
1
4
45
6
10
8
22
Output:
True
Input:
4
1
3
12
output:
false| Report Duplicate | Flag | PURGE
Arrays - 1of 1 vote
AnswersWrite program for the following scenario
- APV July 25, 2015 in India for Amazon Wireless
Input Array :- {1,2,3,4,5,5,5,6,7,7}
Output:- 5 is repeated 3 times
7 is repeated 2 times| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - 2of 2 votes
AnswersRound 6
- sonesh July 12, 2015 in United States
Question 3 : You are given a word document, you have to print the words with frequencies. Now print the kth rank word in terms of frequency. Print top k words as well by frequencies| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Coding Sorting - 0of 0 votes
AnswersRound 5
- sonesh July 12, 2015 in United States
Question 5 : Now lets say you are given k number of input streams, each stream have two method implemented, one is ReadNextNumber() and another is WriteToStream(), lets say each of the streams are sorted. How will you return a single sorted stream which contains all the streams data.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Sorting - -1of 1 vote
AnswersRound 5
- sonesh July 12, 2015 in United States
Question 4 : Now lets say you have 1 PB(1000 TB) of numbers, what kind of system you would prefer, not that you can't store this data in one box. How will you sort these many numbers, what is the time complexity in seconds ?. does increasing core per machine help here ?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures Distributed Computing Sorting - -1of 1 vote
AnswersRound 4
- sonesh July 12, 2015 in United States
Question 3 : this question was similar to Round 2 Question No 3, which is basically convert row type of data to column type of data| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures - -1of 1 vote
AnswersRound 3
- sonesh July 12, 2015 in United States
Question 2 : You are given a array of integers, array may have duplicates, you have to find out the rank k number, and then print out the k highest numbers ?
Required complexity is O(N) + O(1) space, duplicates may be an issue, on which she wanted me to put more focus.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures - 2of 2 votes
AnswersTech Screening
- sonesh July 02, 2015 in United States
Question 1 : You will be given a stream of integers, and a integer k for window size, you will only receive the streams integers one by one. whenever you receive an integer, you have to return the maximum number among last k integers inclusive of current entry.
Interviewer was expecting O(N) solution for N asks.
Edits: Interviewer was expecting O(N) Time + O(1) avg case space complexity solution for N asks.
and integers are not given in a array, every time only one integer will be passed as input to your method.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures - 0of 0 votes
AnswersTech Screening round
- sonesh June 25, 2015 in United States
Q.1 : a non decreasing sorted array is rotated by some random amount, write a routine to figure out this random amount.you can consider the clockwise rotation.
Write the test cases for it.
Interviewer wanted to see prod ready code.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm Arrays Coding - 0of 0 votes
AnswersGiven an array of integers (+ve & -ve) find two equal sized contiguous non-overlapping sub-arrays with maximum dot-product
- JSDUDE June 23, 2015 in United States for Customer experience| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer Algorithm Arrays - 0of 0 votes
Answersgiven an array with elements check if just by exchanging two elements of the array we get a sorted array.
- venuskoti June 10, 2015 in India for xyz| Report Duplicate | Flag | PURGE
xyz Developer Program Engineer Arrays - 3of 3 votes
AnswersRotate a array by N. N can be smaller of greater than the array length.
- someone June 10, 2015 in United States
e.g {0,1,2,4,5,6,7} N =4 should return {5,6,7,4,0,1,2}.
1) I did this using extra array but next I was asked to do without extra array and in o(n) time.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 4 votes
Answersi18n (where 18 stands for the number of letters between the first i and the last n in the word “internationalization,”) Wiki it.
- Gcrack May 22, 2015 in United States
Generate all such possible i18n strings for any given string. for eg. "careercup"=>"c7p","ca6p","c6up","car5p","ca5up","care4p","car4up","caree3p","care3up"..till the count is 0 which means its the complete string again.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm Arrays