Algorithm Interview Questions
- 0of 0 votes
AnswersHumanitarian: Philanthropy is as
- WonderWoman June 04, 2016 in United States
Fan: Notoriety
Thief: Larceny
Donor: Gratitude
Expert: apprenticeship
Scholar: Plagiarism| Report Duplicate | Flag | PURGE
Epic Systems Student Algorithm - 0of 0 votes
AnswerI have two coins that add up to 55 cents. One of them is not a nickel.
- WonderWoman June 04, 2016 in United States
What are the two coins?| Report Duplicate | Flag | PURGE
Epic Systems Student Algorithm - 3of 3 votes
AnswersGiven an array of length N and an integer K, sort the array as much as possible such that no element travels more than k positions to its left - an element however can travel as much as it likes to its right.
- testing@123 June 01, 2016 in United States| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 0of 0 votes
AnswersGiven deck of cards let se 50 cards, now all are thrown on a table, after throwing some cards of them are now with face up and some are with face down, tell the probability of sum of all the face up cards is divisible by 7.
- Ajay Kumar May 29, 2016 in United States for Google Docs
Assume cards from 1 to 10, Answer should be generic so that we can get results for any number of cards, don't compare cards with playing cards, cards can be numbered from 1 to n| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersFind the uncommon elements from 2 lists.
- shivamdev31 May 29, 2016 in India
I/P :
List 1 : 1, 2, 3, 4, 5
List 2 : 3, 4, 5, 6, 7
O/P : 1, 2, 6, 7
I/P :
List 1 : 1, 2, 3, 1, 5
List 2 : 3, 4, 5, 6, 7
O/P : 1, 1, 2, 6, 7
Most probably using space O(n)| Report Duplicate | Flag | PURGE
Android Engineer 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 - 0of 0 votes
AnswersEliminate all the anagrams from an Array of 100 Strings!
- PS May 26, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersGiven an api which returns an array of chemical names and an array of chemical symbols, display the chemical names with their symbol surrounded by square brackets:
- abcpiipii May 25, 2016 in United States
Ex:
Chemicals array: ['Amazon', 'Microsoft', 'Google']
Symbols: ['I', 'Am', 'cro', 'Na', 'le', 'abc']
Output:
[Am]azon, Mi[cro]soft, Goog[le]
If the chemical string matches more than one symbol, then choose the one with longest length. (ex. 'Microsoft' matches 'i' and 'cro')
My solution:
(I sorted the symbols array in descending order of length and ran loop over chemicals array to find a symbol match(using indexOf in javascript) which worked. But I din't make it through the interview, I am guessing my solution was O(n2) and they expected an efficient algorithm.| Report Duplicate | Flag | PURGE
Uber Software Engineer Algorithm String Manipulation - 1of 1 vote
AnswersGiven a binary tree, whose leaf nodes are connected,
- guptasunny158 May 24, 2016 in India
1
/ \
2 3
/ \ /
4 5 6
Now 4,5,6 are leaf nodes in the above BT, 4->5->6
4's left is pointing to 6 and 6's right is pointing to 4. We have a circular DLL of leaf nodes.
We need to find the height of this tree?| Report Duplicate | Flag | PURGE
Adobe Computer Scientist Algorithm - 0of 0 votes
AnswersGiven a string find biggest palindrome substring. For example for given string "AABCDCBA" output should be "ABCDCBA" and for given string "DEFABCBAYT" output should be "ABCBA".
- Preeti May 24, 2016 in United Kingdom| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Algorithm - 0of 0 votes
AnswersYou are given a structure msg
- neer.1304 May 24, 2016 in United States
struct msg
{
long timestamp;
double price;
string label;
};
The msg represents price of a stock on a given timestamp.
Create a class with two functions -
addStockPrice(msg m) -> Used to add Stock Price in Data structure
getAvgPriceForAStockLast10Minutes(String stockName) -> Get average price of a stock for last 10 minutes.
The program should be time and space optimized.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersFind number of islands of '1' in D dimensional array containing '0', '1'. where D > 2.
- prakhar.asthana04 May 24, 2016 in United States| Report Duplicate | Flag | PURGE
xyz SDE-2 Algorithm - 0of 0 votes
Answers...
- anonymous May 23, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersGiven an MxN matrix, determine whether a path can be drawn through every node in the matrix such that the end node is next to the start node, and each node is only touched once.
- geekofthegeeks May 23, 2016 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven a binary tree, find the largest subtree having atleast two other duplicate subtrees .
- geekofthegeeks May 22, 2016 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven the following decoder, write the encoder. (The encoder should be written to compress whenever possible):
- geekofthegeeks May 22, 2016 in United States
p14a8xkpq -> p14akkkkkkkkpq
(8xk gets decoded to kkkkkkkk. The only other requirement is that encodings be unambiguous)
Note that the String can have any possible ascii character| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
Answersgiven 2 strings A and B. generate all possible solutions when B is merged in A.
- JerryGoyal May 22, 2016 in India
Ex: A = "hey"
B: "sam"
then solutions are :
heysam,hseaym,hesaym,sahemy etc.
notice that order should be the same for both of strings while merging.| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 0of 0 votes
AnswersWrite algorithm to find mid element in the linked list
- basav.d May 19, 2016 in India for Release Mgmt| Report Duplicate | Flag | PURGE
JP Morgan SDE-3 Algorithm - 2of 2 votes
AnswersA museum was represented by a square matrix that was filled with O, G, and W where O represented open space G represented guards, and W represented walls. Write a function that accepts the square matrix and returns another square matrix where all of the O's in the matrix are replaced with the number of how many spaces they are away from a guard, without being able to go through any walls.
- fire May 17, 2016 in United States| Report Duplicate | Flag | PURGE
Facebook Android Engineer Algorithm - 1of 1 vote
AnswersYou are given a string "abc" which is encoded like "123" where alphabets are mapped like a => 1 to z => 26. Now find out how many string can be formed by reverse engineering encode string "123".
- sachin323 May 16, 2016 in United States
For ex. given string "123" we can form 3 string "abc"(1,2,3), "lc" (i.e 12,3), "aw"(1,23).
for string "1234" we have following possible combinations, I might be missing some of them but you get the idea
{12, 3, 4}
{1, 23, 4}
{1, 2, 3, 4}| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersU have given a undirected weighted graph. U have to create Spanning tree (not MST). The Property is the difference between the min and max edge weight of Spanning edges should be min.
- yogi May 15, 2016 in India| Report Duplicate | Flag | PURGE
Intel Computer Scientist Algorithm - -1of 1 vote
AnswersInput: set of coordinates = [P1,P2,...,Pi,.....Pj,....Pn]
- prince May 13, 2016 in India
P denote Point(x,y)
Start point is any of set of coordinates like Pi
simily end point is also any of set of coordinates like Pj.
Find the shortest path with set of points between start and end points.
Let us have a simple example
Set of coordinates :
P4 P5 P6
P1 P2 P3 P7 P8 P9 P11 P12 P13
P10
Start Point: P2
End Points: p12
Output: P2,P3, P7,P8,P9,P11,P12| Report Duplicate | Flag | PURGE
Adobe Computer Scientist Algorithm - 0of 0 votes
Answers// Reverse the words. Given a String that contains words separated by single space, reverse the words in the String. You can assume that no leading or trailing spaces are there.
// For example: "Man bites dog" => "dog bites Man”
- almunayer May 10, 2016 in United StatesString reverseWords(String value) { // Insert implementation }
| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersSelect Kth largest value in the array. Given an unsorted array of size n, and a value k. Select the kth largest value from the array.
For example:
Array is [5, 3, 9, 1], n is 4
k = 0 => 9
k = 1 => 5
k = 3 => 1
- almunayer May 10, 2016 in United Statespublic int kthLargest(int array[], int k) { // ..... }
| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersDesign a hashMap in Java. Implement put, get, remove, resize methods.
- xankar May 10, 2016 in United States| Report Duplicate | Flag | PURGE
Uber Software Developer Algorithm - 0of 0 votes
AnswersGiven a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
- xankar May 10, 2016 in United States
For example, given
s = "leetcode",
dict = ["leet", "code"].
Return true because "leetcode" can be segmented as "leet code".| Report Duplicate | Flag | PURGE
Uber Software Developer Algorithm - 0of 2 votes
AnswersGiven a list of pies (and the number of slices in each pie) calculate the maximum number of slices that nPeople could receive if each person got the same amount of slices and did not get slices from more than 1 pie.
- Dinkleberg May 09, 2016 in United Statespublic int getMaxSlices(List<Integer> pieSlices, int nPeople) { // return answer }
| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersWrite a program to find all duplicate files within a folder.
- sw May 08, 2016 in United States| Report Duplicate | Flag | PURGE
Dropbox SDE1 Algorithm