Recent Interview Questions
- 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
AnswersWrite a code in C for the following:
- jeanclaude July 09, 2012 in United States
Starting from 1, assign an alphabet to each integer, for e.g. if input is 1 then A should be the output), 2 = B ....... 26 = Z. Similarly, 27 = AA, 28 = AB..........52 = AZ. 702 = ZZ, 703 = AAA and so on. The function takes only one integer argument . for e.g ConvertToAphabet(int x). One additional consideration here is, the user is free to provide any length of integer (bigint long int etc), no restriction there.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C - 0of 0 votes
AnswersAmazon telliphonic 17 May, 2012
- adarsh May 17, 2012 in India
1.) There is a sequence where aphabets are written like this..
a,b,c,d,.......,x,y,z,aa,ab,ac........,az,ba,bb,bc,bd......bz,ca,cb.........cz........,aaa,aab,aac.....aaz,............zzz,aaaa...........zzzz..... and so on..
WAP to find out the string value at kth position.
like if k= 28 the string on 28 will be "ab".| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersQ1. F2F Round 1 Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a character array as input. Array contains only three types of characters 'R', 'G' and 'B'. Sort the array such that all 'R's comes before 'G's and all 'G's comes before 'B's.
Constraint :- No extra space allowed(except O(1) space like variables) and minimize the time complexity.
You can only traverse the array once.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C C# C++ Coding Data Structures Java Sorting - 0of 0 votes
AnswersHow will you count the number of students in a classroom in quickest possible manner.
- Kevin March 13, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Financial Software Developer Brain Teasers - 0of 0 votes
AnswersGiven 2 dimensional sorted array(Both row and column wise sorted) write a efficient code to find median.
- cxc January 01, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an integer n, write code to calculate n+1, without using +,-,++,--,*,/
- deep July 01, 2011| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - -1of 1 vote
AnswersGiven a unsorted array, there is one element where a[i]==i . find the element in logn
- joman May 16, 2011| Report Duplicate | Flag | PURGE
Huawei Software Engineer / Developer Arrays - 3of 3 votes
AnswersSuppose we are given an array A[1 .. n] with the special property that A[1] ≥ A[2] and
- Anonymous March 24, 2011
A[n − 1] ≤ A[n]. We say that an element A[x] is a local minimum if it is less than or equal
to both its neighbors, or more formally, if A[x − 1] ≥ A[x] and A[x] ≤ A[x + 1]. For example,
there are five local minima in the following array:
9 7 7 2 1 3 7 5 4 7 3 3 4 8 6 9
We can obviously find a local minimum in O(n) time by scanning through the array. Describe
and analyze an algorithm that finds a local minimum in O(log n) time.| Report Duplicate | Flag | PURGE
Google Algorithm - 1of 1 vote
AnswersI have a lottery ticket. Each of these lottery tickets has a 6 digit number on it. The winning lottery tickets are those whose sum of the first three digits is equal to the sum of the last three digits. How many possible winning tickets are there?
- Sonny January 14, 2011
Note: Leading ‘ZEROES’ are counted. So a number like 004103 is a valid winning ticket since 0+0+4 = 1+0+3.| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Brain Teasers - 0of 0 votes
AnswersImplement Stack with Push() Pop() and Mininum() operation in O(1).
- talk2arpit August 16, 2010| Report Duplicate | Flag | PURGE
Microsoft unknown Software Engineer / Developer Algorithm - 0of 0 votes
Answershow to find Nth largest element in an array,complexity o(n)
- nav September 02, 2009| Report Duplicate | Flag | PURGE
Ebay Software Engineer / Developer - 0of 2 votes
AnswersA river separates two banks, there are 3 men and 3 lions on one side that need to be taken across using a boat that can carry 2 entities at a time(irrespective of being a lion and man), subject to the condition that at no point can you have more number of lions than men on any bank, as then the lions would eat the man/men. Solve the puzzle. Then code it to make it a generic program that solves the puzzle for X men and Y lions.
- me December 27, 2008
3-3 is easy, generalization is a bit problematic.| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Brain Teasers - -1of 0 votes
AnswersHow do you merge n sorted lists with average length K in O(n*log(K)) time?
- ss December 06, 2006| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersA = "ffgggtvshjsdhjfffffffhvjbjcharu"
- SPS March 14, 2017 in India
Find the max consecutive repitative chracter
Output : f -> 7| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Online Test - 4of 4 votes
AnswersReturn the length of longest possible chunked palindrome string.
- AlgoBaba December 08, 2016 in United States
Examples :
Input : VOLVO
Output : 3
Explanation :
(VO)L(VO)
Input : merchant
Output : 1
Explanation : No chunks possible.
Input :
ghiabcdefhelloadamhelloabcdefghi
Output : 7
Explanation :
(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven k - which is the number of bits, print all the possible combinations of numbers formed by printing all numbers with one bit set, followed by two bits set, ... upto the point when all k-bits are set. They must be sorted according to the number of bits set, if two numbers have the same number of bits set then they should be placed as per their value.
- theconqueror May 27, 2016 in India
For example if K=3
Output:
000, 001, 010, 100,101, 110, 011, 111
0 bits set, followed by 1 bits set followed by 2 bits set followed by 3 bits set.| Report Duplicate | Flag | PURGE
Google Algorithm - 2of 2 votes
Answersfind consecutive integers in a list that give you the biggest sum
- J@sper February 09, 2016 in United States
Like for -2 5 -1 7 -3 it would be 5 -1 7| Report Duplicate | Flag | PURGE
Google Java - 6of 6 votes
AnswersGiven a sorted array of size N of int32, find an element that repeats > ceil(N / 2) times. Your algo may assume that there will be always such element. Space/time O(1).
- emb January 18, 2016 in United States
Follow up question: Now element repeats > ceil(N / 4) times. Space/time O(1)| Report Duplicate | Flag | PURGE
Google Intern - 1of 5 votes
AnswersYou are given an array of n unique integer numbers 0 <= x_i < 2 * n
- emb September 23, 2015 in United States
Print all integers 0 <= x < 2 * n that are not present in this array.
Example:
find_missing([0]) = [1]
find_missing([0, 2, 4]) = [1, 3, 5] # because all numbers are [0, 1, 2, 3, 4, 5]
find_missing([]) = []
find_missing([0, 1, 4, 5]) = [2, 3, 6, 7] # because all numbers are [0, 1, 2, 3, 4, 5, 6, 7]
Quirks are about requirements:
Time complexity O(n) - BUT there should be some fixed constant C independent of size of input such that every element of array is written/read < C times, so radix sorting the array is a no go.
Space complexity O(1) - you may modify the initial array, BUT sorted(initial_array) must equal sorted(array_after_executing_program) AND you can't store integers outside range [0, 2n) in this array (imagine that it's an array of uint32_t).| Report Duplicate | Flag | PURGE
Google Software Engineer Brain Teasers - 6of 6 votes
AnswersPost order traversal for an N-ary tree iterative way.
- hm September 14, 2015 in United States
Given,
struct Node {
int val;
vector<Node*> children;
};
Without modifying original structure.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm C++ Trees and Graphs - 3of 3 votes
AnswersGiven n light bulbs, write two methods.
- cup August 19, 2015 in United States
isOn(i) to determine if a light bulb is on
toggle(start, end) to toggle all the light bulbs in the range
One caveat, write toggle so that it is less than O(n) complexity| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersGiven an array of integer, find the maximum drop between two array elements, given that second element comes after the first one.
- diwash.timilsina August 04, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 1of 3 votes
AnswersOn a given array with N numbers, find subset of size M (exactly M elements) that equal to SUM.
- coredo August 02, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven an bunch of airline tickets with [from, to], for example [MUC, LHR], [CDG, MUC], [SFO, SJC], [LHR, SFO], please reconstruct the itinerary in order,
- blah_blah May 18, 2015 in United States
for example: [ CDG, MUC, LHR, SFO, SJC ].
//tickets can be represented as nodes| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 2 votes
Answerswrite a prog/method to convert number to character (as in old mobile phone).
- Anonymous May 03, 2015 in United States
e.g. 2 entered 1 = A
2 entered 2 = B
2 entered 3 = C
# = space
22#22 = B B etc.| Report Duplicate | Flag | PURGE
Epic Systems Java Developer Algorithm - 0of 0 votes
AnswersWrite a function to determine if a string is a number without using any built-in function.
- Raul Rivero January 13, 2015 in United Statespublic bool IsNumber(string num) { }
| Report Duplicate | Flag | PURGE
Linkedin Front-end Software Engineer Algorithm - 0of 0 votes
AnswersYou are given a string 's' and you are given a dictionary of english words. You goal is to write an algorithm that returns all words from the dictionary the can be formed by characters from that string 's'.
- autoboli January 07, 2015 in United States
Example:
s = "ogeg"
following words can be formed from 's': go egg ego . . .
Further it is given that string 's' always consists of four lower case characters. Lets say that the dictionary is contained in a file and can be fitted in the memory. It is up to you which data structure you use to represent the dictionary.
How would you design an efficient algorithm? Follow up: What if the dictionary file can not be fitted in the memory?| Report Duplicate | Flag | PURGE
Google - 1of 1 vote
AnswersYou are given an array, that is sorted, however was rotated to the right by a certain distance. The array may contain duplicated values. Find the index of a given element in the array.
- joe kidd August 03, 2014 in India
Example: {3, 9, 9, 9, 8, 10, 12, 13, 1, 2, 3}, element = 3, returns, any of indexes that 3 is present.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm