Algorithm Interview Questions
- 0of 0 votes
AnswersLRU Cache
- anonymous May 03, 2016 in United States| Report Duplicate | Flag | PURGE
Uber Senior Software Development Engineer Algorithm - 1of 1 vote
AnswersWAP to take one element from each of the array add it to the target sum. Print all those three-element combinations.
- xankar April 28, 2016 in United States
/*
A = [1, 2, 3, 3]
B = [2, 3, 3, 4]
C = [1, 2, 2, 2]
target = 7
*/
Result:
[[1, 2, 4], [1, 3, 3], [1, 3, 3], [1, 3, 3], [1, 3, 3], [1, 4, 2], [2, 2, 3], [2, 2, 3], [2, 3, 2], [2, 3, 2], [3, 2, 2], [3, 2, 2]]| Report Duplicate | Flag | PURGE
Uber Senior Software Development Engineer Algorithm - 0of 0 votes
AnswersWrite a function that takes a string representing as value in roman numbers and returns it as an integer.
- joey April 28, 2016 in United StatesImplement the following /** * * romanNumber("III") = 3 * romanNumber("IV") = 4 */ int romanNumber(String roman) { // ... }
| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersWrite a function that takes a number and returns the square root
- joey April 28, 2016 in United StatesImplement the following double sqrt(double d) { // ... }
| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersThere is a KILL command which removes a variable and its value from the symbol table, thus undefining it. The syntax for the KILL is:
- jaq0033@my.londonmet.ac.uk April 27, 2016 in united kingdom
K A KILL command followed by 2 spaces kills all variables. K VAR The variable VAR is killed, if it exists.
K (VAR,VAS) All variables except VAR and VAS are killed.
The most common use of KILL is to free storage space. Another use is to flag conditions - if a particular value is defined, that means one thing; and if it is undefined, that means something else.
Question: K S S="4",T=S+2,Z=T>6 K K, J, S What variables are defined and what are their values?
A. T=6,Z=” “
B. T=”6”, Z=0
C. S=”4”,T=6,Z=0
D. S=”4”,T=”6”,X=”0”
E. S=”4”,T=”6”,Z=”FALSE”
F. S=”4”,T=”S+2”,Z=”T>6”
G. No variables are defined| Report Duplicate | Flag | PURGE
Algorithm - 2of 2 votes
AnswersYou are designing a system the records website visits. The interface for this system is:
- taylor.halliday April 26, 2016 in United States
void recordHit();
long getCount();
`getCount()` returns the amount of hits to the site for only the last 5 minutes.
Your task is to code `recordHit()` and `getCount()`| Report Duplicate | Flag | PURGE
Dropbox Software Engineer Algorithm - 1of 1 vote
AnswersThis is a question I received in an online challenge.
- sparked12345 April 22, 2016 in United States
A list of numbers are given. We need to find the total number of groups in which the digits of each number have same frequency.
For example if numbers are:
1
10
3
33
There are 4 groups:
G1={1}has one 1.
G2={3} has one 3.
G3={10}has one 1 and one 0.
G4={33}as two 3s.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - -16of 18 votes
AnswersDoes Google/Microsoft/Amazon/Facebook allow Golang in coding interviews?
- amit April 20, 2016 in India| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven a dictionary of strings and another string find out if the string is an exact match to some words in the dictionary or varies at most in only one place of some word of the dictionary?
- amit April 20, 2016 in United States| Report Duplicate | Flag | PURGE
Algorithm - 1of 1 vote
AnswersFind the anagrams from a list of strings
- coder145 April 19, 2016 in United States
Input : {"tea", "ate", "eat", "apple", "java", "vaja", "cut", "utc"}
Output : {"tea", "ate", "eat","java", "vaja", "cut", "utc"}| Report Duplicate | Flag | PURGE
Twitter Senior Software Development Engineer Algorithm - 0of 0 votes
AnswersGiven a stream of characters (e.g. acacabcatghhellomvnsdb) and a list of words (e.g. ["aca","cat","hello","world"] ) find and display count of each and every word once the stream ends.(Like : "aca" : 2 , "cat" : 1 , "hello" : 1 , "world" : 0 ).
- badebhaiyya April 16, 2016 in United States| Report Duplicate | Flag | PURGE
Booking.com Software Developer Algorithm - 8of 8 votes
AnswersYou are given a graph, some edges are black, some are red. Find a spanning tree with one restriction: if we take some node as root, every path from it to some leaf node must consist of alternating red-black-red-black edges. That is, no path from root to leaf must contain sequential black-black edges or red-red edges.
- emb April 12, 2016 in United States
You are guaranteed that such spanning tree exists.| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 0of 0 votes
AnswersFind out if there is cycle in Directed graph
- pc April 09, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Algorithm Data Structures - -1of 1 vote
AnswersGiven billions of Rectangle, find rectangle with minimum area overlapping to a given point P(x,y)
- pc April 09, 2016 in United States
There is a simple way to achieve answer in O(n) by processing each rectangle sequentially, but optimize it further provided large number of Rectangle array.| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Algorithm Data Structures - 0of 0 votes
AnswersYou are given a graph and a node in the graph. Group the nodes connected to this node if they are also connected to each other. For example, the graph has nodes 1, 2, 3, 4, 5 where 1 is connected to 2, 3, 4; 2 and 3 are also connected to each other, 4 is just connected to 1 and 5 is a separate node. You are given node 1 as input. Output should be:
- doomguy April 05, 2016 in United States
2 3
4| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersThere are N coins with coordinates (x, y) where x >0 and y >0
- emb April 02, 2016 in United States
You start at (0, 0) and you can only do steps of form (dx, dy) where dx >0 and dy > 0
Print the maximum number of coins that you can collect.
Clarification: you can do as many moves as you wish, the point is to collect maximum number of coins. If you are located at position (a, b) you may jump to position (a+dx, b+dy) for all dx > 0 and dy > 0
@krbchd: Your algorithm may output incorrect values. Suppose there are points (5, 7), (5, 8), (5, 9) for y coordinates LIS will output 7, 8, 9, however since these points are on the same x axis, you can choose only one of them.| Report Duplicate | Flag | PURGE
Facebook Software Developer Algorithm - 2of 2 votes
AnswersFind the minimum (index) distance sum of 3 words. For example: arr = {"2", "1", "0", "2", "0", "3", "0"}, input = "1","2","3". The result should be 8 since the 2nd "2" and "1", "3"'s distance are 3, 1, 5 and abs(3,1)+abs(3,5)+abs(5,1)=8.
- lifeGoGoGo April 01, 2016 in United States
Implement this in O(N)| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 0of 0 votes
Answersqrtyp
- bcsf13a018@pucit.edu.pk March 29, 2016 in United States| Report Duplicate | Flag | PURGE
Algorithm - 0of 0 votes
AnswersGiven a grid and list of points. Find two points that define the line which divides a set of points into two equal parts.
- megatester6 March 27, 2016 in United States for Software Engineer| Report Duplicate | Flag | PURGE
Algorithm - 0of 0 votes
AnswersThis class will be given a list of words (such as might be tokenized
- oddcoder March 22, 2016 in United States
from a paragraph of text), and will provide a method that takes two
words and returns the shortest distance (in words) between those two
words in the provided text.
Example:
WordDistanceFinder finder = new WordDistanceFinder(Arrays.asList("the", "quick", "brown", "fox", "quick"));
assert(finder.distance("fox","the") == 3);
assert(finder.distance("quick", "fox") == 1);
"quick" appears twice in the input. There are two possible distance values for "quick" and "fox":
(3 - 1) = 2 and (4 - 3) = 1.
Since we have to return the shortest distance between the two words we return 1.| Report Duplicate | Flag | PURGE
Algorithm - -1of 1 vote
AnswersYou are given an array of wooden log’s length. each of varying length.You have a wooden cutter with you. it has a sharpness value, say S.
- alien.0101 March 22, 2016 in India
You are supposed to cut as many wooden logs (desired logs), each of length L (not more or less) using only S cuts
if you cut a wood, S will decrease by 1
if you cut two woods together, even then S will decrease by the number of woods in the cut, ie. 2
assume L and S are int. and the length of each wood is also int| Report Duplicate | Flag | PURGE
Accenture Developer Program Engineer Algorithm - 0of 0 votes
Answershttps://codility.com/programmers/task/fish/
- xu.shenxin March 19, 2016 in United States
I am having huge challenges with this question. It probably uses stack, but I have no idea how to solve it.
Anybody can help me with a sudo code?| Report Duplicate | Flag | PURGE
Algorithm - 0of 0 votes
AnswersGiven an array of numbers, find the longest alternating subsequence. That is, a subsequence [a1, a2, a3, ..., ak] where a1 > a2, a3 < a2, a4 > a3, ... or vice versa (Graphically looks like /\/\/\... or \/\/\/\....
- emb March 19, 2016 in United States| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 1of 1 vote
AnswersGiven a string S, print the longest substring P such that P > S lexicographically.
- emb March 16, 2016 in United States
You may assume that such substring exists.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 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 - 1of 1 vote
AnswersGiven a number print the number of combinations you can derive from the number. 1=A, 2=B, 26=Z, 0=+.
- SHR March 14, 2016 in India
For example: 1123 can be represented by 1,1,2,3 which would stand for AABC.
Another representation - 11,23 - JW
Another representation - 1,1,23 - AAW
Another representation - 11,2,3 - JBC
For number 1123, there will be 5 combinations.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersIn a binary tree, find and print the path with smallest weight.
- SHR March 14, 2016 in India
Criteria: the tree contains integer values in the nodes. It may not be balanced tree. Weight is calculated by sum of values in the nodes in that path. Write code that returns the path as well as the minweight.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm