Recent Interview Questions
- 2of 2 votes
Answersinput:
- S.Abakumoff February 25, 2013 in United States
sum - the integer amount
n - the number of coins
d - the array contains the coins denominations
WAP that prints all the possible non-repeated combinations of n coins of denominations from d that sum up to n.
Sample of input:
d={1,5,10,15}
sum = 30
n = 6
The expected output:
1,1,1,1,1,25
5,5,5,5,5,5| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersDesign an LRU cache with all the operations including getting the least recently used item to be O(1).
- Anonymous November 06, 2009| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersAlgorithm: You have 50,000 html files, some of which contain phone numbers. How would you create a list of all the files which contain phone numbers?
- Gayle L McDowell April 04, 2005| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer System Design Algorithm - 2of 2 votes
AnswersYou have a string of numbers, i.e. 123. You can insert a + or - sign in front of ever number, or you can leave it empty. Find all of the different possibilities, make the calculation and return the sum.
- twinmind March 03, 2017 in United States
For example;
+1+2+3 = 6
+12+3 = 15
+123 = 123
+1+23 = 24
...
-1-2-3 = 6
...
Return the sum of all the results.| Report Duplicate | Flag | PURGE
Facebook Software Developer Algorithm - 2of 2 votes
Answersfor given array
s[] = {5,1,0,4,2,3}
1) length of array is not given.
- idforbc November 24, 2015 in United States
2) If length of array is 5 content is guaranteed to be between 0 to 5. There is no repetition of numbers. Sample example for length(s, 3)
- a[3] = 4 , a[4] = 2, a[2] = 0, a[0] = 5, a[5] =3
returns length of 4 .
For given condition write subroutine
int length (s, 3)
- to find the number of steps it takes to find given value - It's a function api - that I was asked to write with the conditions - I cannot change parameters of the function - I have to make sure return value is correct
Additional Condition:
You cannot use any loop statements like for, while and so on -
You cannot use any global or static variables.
You cannot call other routines inside this routine
You cannot modify given function parameters - it stays length (s, n) only
You cannot change original array too| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWrite a function to test if the given set of brackets are balanced or not. e.g. {{}}{)([][]
- Qasim November 12, 2015 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Developer Algorithm - 2of 2 votes
AnswersYou are given two arrays - A & B. The length of the arrays is the same - N. The values in the arrays are integers from 0 to N - 1 in random order and no number is repeated. You need to list a sequence of two-element swaps required to reorder the array A into the order of the array B. Additionally, at each step of the sequence you are allowed to swap two elements only if one of them is 0.
- tested.candidate March 21, 2015 in UK| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersGiven a 4 X 4 game slot that has random alphabets in all the slots
- JSDUDE January 16, 2015 in United States
Write a function that takes the keyboard and the word as input and returns true if the word can be formed
False otherwise.
A word can be formed on the board by connecting alphabets adjacent to each other (horizontal, vertical and diagonally)
Same alphabet should not be reused.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven a large array of unsigned ints, quickly find two who's sum is 10
- JSDUDE November 22, 2014 in United States for Software Developer, Infrastructure Planning, Analysis and Optimization
Then the interviewer asked me to write test cases.
Followed by how to implement this on a distributed system, where multiple systems can read/write simultaneously on a shared cache (HINT: It is ok if you do not return the first instance)| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Arrays - 2of 2 votes
AnswersGiven N sets of integers, remove some sets so that the remaining all sets are disjoint with one another. Find the optimal solution so that the number of sets remaining at the end is maximum
- Rahul Sharma July 12, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
Answersgiven a binary tree and a leaf node. holding a leaf node and whole tree falls down such that it is the new root of the tree. return the modified tree.
- Nascent June 07, 2014 in India| Report Duplicate | Flag | PURGE
Amazon - 2of 2 votes
AnswersMapping
- Thiago January 13, 2014 in United States
'1' = 'A','B','C'
'2' = 'D','E','F'
...
'9' =
input: 112
output :ouput = [AAD, BBD, CCD, AAE, AAF, BBE, BBF, CCE, CCF]| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven a 2D rectangular matrix of boolean values, write a function which returns whether or not the matrix is the same when rotated 180 degrees.
- nr June 06, 2013 in United States for maps| Report Duplicate | Flag | PURGE
Google SDE1 - 2of 2 votes
AnswersConsider a system of n nodes numbered 1 to n. Each node has its id(1 to n) and a value associated with it say val. Now Every node has a send method send(int to , int val) and receive method int receive(int from).
- sowmya February 20, 2013 in United States
So if node 1 wants to send value , it does like this . send(1,val).
Using these two methods, write a distributed algorithm. Such that when the algorithm finishes, every node in the system knows the sum of the values of all the nodes in the system.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven an array of red, green and blue balls arrange them in groups of all red together, greens together and blue together. Do in a single scan of the array.
- me December 27, 2008
This is same as You have an array containing only '0's, '1's and '2's. Club same items together in single scan.| Report Duplicate | Flag | PURGE
Google Software Engineer in Test - 2of 2 votes
AnswersGenerate random max index
- acoding167 March 27, 2019 in United States
Given an array of integers, randomly return an index of the maximum value seen by far.
e.g.
Given [11,30,2,30,30,30,6,2,62, 62]
Having iterated up to the at element index 5 (where the last 30 is), randomly give an index among [1, 3, 4, 5] which are indices of 30 - the max value by far. Each index should have a ¼ chance to get picked.
Having iterated through the entire array, randomly give an index between 8 and 9 which are indices of the max value 62.| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 2of 2 votes
AnswersGiven an integer, print an English phrase that describes the integer (eg, "Two hundred and thirty four", “One Thousand, Two Hundred and Thirty Four”)
- MM2181 August 19, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Web Developer - 2of 2 votes
AnswersGiven 2 strings representing very large numbers (these are not representable as a BigInteger or other various type) write a method for adding the two numbers and returning their sum.
- Scott.T.Rogers July 06, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Senior Software Development Engineer Algorithm - 2of 2 votes
AnswersMove[inplace] the non zero elements at the one end(end of array) and return the numbers of non zero elements in output array
- rituraj.raj March 28, 2018 in India for London office
Solution : https://www.geeksforgeeks.org/move-zeroes-end-array/| Report Duplicate | Flag | PURGE
Facebook Android Engineer - 2of 2 votes
AnswersGIven a string "str" and pair of "N" swapping indices, generate a lexicographically largest string. Swapping indices can be reused any number times.
- uvm March 15, 2016 in United States
Eg 1)
String = "abdc"
Indices:
(1,4)
(3,4)
Answer:
cdba, cbad, dbac,dbca
you should print only "dbca" which is lexicographically largest.| Report Duplicate | Flag | PURGE
Facebook SDE-2 Algorithm - 2of 2 votes
AnswersGiven a dictionary containing a list of words, a starting word, and an ending word, return the minimum number of steps to transform the starting word into the ending word.
- ixnay October 28, 2015 in United States
A step involves changing one letter at a time to a valid word that is present in the dictionary.
Return null if it is impossible to transform the starting word into the ending word using the dictionary.
Example:
Starting word: cat
Ending word: dog
cat -> cot -> cog -> dog ('cot' and 'cog' are in the dictionary)
return 3| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 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 - 2of 2 votes
AnswersLink all the level order nodes to makes a linked list with the first node of each level acting as the root of that linklist.
- catlover February 27, 2015 in India
10
/ \
6 17
/ / \
4 14 19
So the Linklist will be
10->null
6->17->null
4->14->19->null| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersGiven a number give its english form
- IntwPrep.MS January 17, 2014 in United States for Bing
1-> One
999 -> Nine hundred and ninety nine
Max number is: 999, 999, 999| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer - 2of 2 votes
AnswersWAP to create a mirror of a binary tree. Extend the code or write a new code if not possible to do mirroring at alternate levels . Here in the second part , if the two trees are placed in front of each other , then odd levels should be exact mirror as a whole and even levels should be exactly same . Then write the iterative version for the above codes.
- Kavish Dwivedi July 15, 2013 in India for Bangalore| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - 2of 2 votes
AnswersWrite a program to swap kth node from first and kth node from last in a linked list .
- Coder April 18, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven an integer array, return the combinations of 4 array values whose sum is x
- Guest SVM April 12, 2013 in United States for AWS
Eg:
Input int array = {1,2,3,5,0,-2}
Return all possible combinations such that
a+b+c+d = 1
Like: -2 , 0 , -2 , 5
2 , -2 , 0 , 1, etc...| Report Duplicate | Flag | PURGE
Amazon Senior Software Development Engineer Algorithm - 2of 2 votes
Answersgiven a stream of quotes for a stock from the last trading day. Assume its already time sorted. Find the maximum amount of money you could have made on this stock by making at most N transactions. A buy and a sell is counted as one transaction. For parts N = 1, N = 2 and N = Inf and the generic solution for N = some number (open ended)
- Steve September 11, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm