Recent Interview Questions
- 2of 2 votes
AnswersHow would you store the relations in a social network like Facebook and implement a feature where one user receives notifications when their friends like the same things as they do?
- tested.candidate July 13, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer System Design - 2of 2 votes
AnswersHow will you serialize the binary tree ?
- algeek July 08, 2015 in India| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 2of 2 votes
AnswersConstructing Bridges:
- R@M3$H.N December 25, 2014 in India
A River that cuts through a set of cities above and below it. Each city above the river is matched with a city below the river.
Construct as many Non-Crossing Bridges as possible.
Input:
Above Bank >> 7 4 3 6 2 1 5
Below Bank >> 5 3 2 4 6 1 7
are given in pairs: (7,5) (4,3) (3,2) (6,4) (2,6) (1,1) (5,7)
Output:
(1,1) (3,2) (4,3) (6,4) (7,5)| Report Duplicate | Flag | PURGE
StartUp SDE-2 Algorithm Data Structures - 2of 2 votes
AnswersI/P: An array of Integers: which will be used to construct a binary search tree in the order they appear.
- poorna.chandra.akp April 20, 2014 in India
o/p: all permutations of the input elements which will result in the same Binary Search tree as the one formed with the input array.
Eg:
I/P: 4, 3, 1, 2, 6, 5, 7
o/p:4 , 6, 3, 7, 5, 1, 2
4, 3, 2, 1, 6, 5, 7
and soo on.| Report Duplicate | Flag | PURGE
Directi Senior Software Development Engineer - 2of 2 votes
AnswersGiven an input list of lists.. flatten the list. For e.g.
- techpanja October 22, 2013 in United States for yammer
{{1,2}, {3}, {4,5}} ... Output should be {1, 2, 3, 4, 5}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 2of 2 votes
AnswersThe probability of a bus passing through a certain intersection in a time window of 20 min. is 0.9
- Abhinav April 27, 2013 in India
What is the probability of the same bus passing through the same intersection in 5 min.| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Probability - 2of 2 votes
AnswersSelect a random node data from a very long linked list whose length is not known such that the probability of each node is equal.
- ishwant.nandra January 17, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Linked Lists - 2of 2 votes
AnswersWe define the following:
- new September 22, 2017 in United States
There are friends_nodes friends numbered from 1 to friends_nodes.
There are friends_edges pairs of friends, where each (xi, yi) pair of friends is connected by a shared integer token described by friends_weighti.
Any two friends, xi and yi, can be connected by zero or more tokens because if friends xi and yi share token ti and friends yi and zi also share token ti, then xi and zi are also said to share token ti.
Find the maximal product of xi and yi for any directly or indirectly connected (xi, yi) pair of friends such that xi and yi share the maximal number of tokens with each other.
Complete the maxTokens function in the editor. It has four parameters:
Name Type Description
friends_nodes integer The number of friends.
friends_from integer array Each friends_from[i] (where 0 ≤ i < friends_edges) denotes the first friend in pair (friends_from[i], friends_to[i]).
friends_to integer array Each friends_to[i] (where 0 ≤ i < friends_edges) denotes the second friend in pair (friends_from[i], friends_to[i]).
friends_weight integer array Each friends_weight[i] (where 0 ≤ i < friends_edges) denotes the ID number of a token shared by both friends_from[i] and friends_to[i].
Note: friends_edges is the number of pairs of friends that directly share a token.
The function must return an integer denoting the maximal product of xi and yi such that xi and yi are a pair of friends that share the maximal number of tokens with each other.
Input Format
The first line contains two space-separated integers describing the respective values of friends_nodes and friends_edges.
Each line i of the friends_edges subsequent lines (where 0 ≤ i < friends_edges) contains three space-separated integers describing the respective values of friends_fromi, friends_toi, and friends_weighti.
Constraints
2 ≤ friends_nodes ≤ 100
1 ≤ friends_edges ≤ min(200, (friends_nodes × (friends_nodes − 1)) / 2)
1 ≤ friends_weighti ≤ 100
1 ≤ friends_fromi, friends_toi ≤ friends_nodes
1≤ friends_weighti ≤ friends_edges
friends_fromi ≠ friends_toi
Each pair of friends can be connected by zero or more types of tokens.
Output Format
Return an integer denoting the maximal product of xi and yi such that xi and yi are a pair of friends that share the maximal number of tokens with each other.
Sample Input 0
4 5
1 2 1
1 2 2
2 3 1
2 3 3
2 4 3
Sample Output 0
6
Explanation 0
Each pair of n = 4 friends is connected by the following tokens:
Pair (1, 2) shares 2 tokens (i.e., tokens 1 and 2)
Pair (1, 3) shares 1 token (i.e., token 1)
Pair (1, 4) shares 0 tokens
Pair (2, 3) shares 2 tokens (i.e., tokens 1 and 3)
Pair (2, 4) shares 1 token (i.e., token 3)
Pair (3, 4) shares 1 token (i.e., token 3)
The pairs connected by the maximal number of tokens are (1, 2) and (2, 3). Their respective products are 1 × 2 = 2 and 2 × 3 = 6. We then return the largest of these values as our answer, which is 6.| Report Duplicate | Flag | PURGE
Google - 2of 2 votes
AnswersIn Docker, building an image has dependencies. An image can only be built once
- ajay.raj August 27, 2017 in United States
its dependency is built (If the dependency is from outside, then the image can
be built immediately).
Sometimes, engineers make mistakes by forming a cycle dependency of local images.
In this case, ignore the cycle and all the images depending on this cycle.
Input is vector of pair of images (image, its dependency).
Output the order of images to be built in order.
##Example:
```
Example 1:
{{"master", "ubuntu"}, {"numpy", "master"}, {"tensorflow", "numpy"}}
Output: master, numpy, tensorflow
Example 2:
{{"python", "numpy"}, {"numpy", "python"}, {"tensorflow", "ubuntu"}}
Output: tensorflow
Example 3:
{{"b", "c"}, {"c", "d"}, {"a", "b"}, {"d", "e"}, {"e","c"}, {"f", "g"}}
Ouput: f| Report Duplicate | Flag | PURGE
Facebook SDE1 - 2of 2 votes
AnswersA binary tree is started burning from a leaf node. What is the time(1ms to burn from node to node) it takes to entire tree get burned? The fire will spread to all the paths from a node.
- SIVA R August 20, 2017 in United States| Report Duplicate | Flag | PURGE
Trees and Graphs - 2of 2 votes
AnswersDesign a FIDS(Flight Information Display System)
- AD August 04, 2017 in India
1. Consider most important classes & ignore Interfaces as of now
2. FIDS is not about reservation system but the dasboard to display
3. the information will look like:
DEPARTURES
----------------------
Attributes:
STD Airline Flight Destination/Via CheckInCounter# Gate Status ETD
Values :
12:50 KingFisher 6E352 Hyderabad A-B 23 Check-In Open 13:15
ARRIVALS
-----------------------
Attributes:
STA Airline Flight# Destination/Via Gate Status ETA
Values :
12:50 KingFisher 6E352 UK/Mumbai Terminal2 Landed 13:15| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 2of 2 votes
AnswersWrite a function that takes an array of positive and negative integers and a number. This function should return true if the array contains a contiguous sub array that sums up to the number (2nd input).
- JSDUDE May 09, 2017 in United States
He wanted an O(n) algorithm.| Report Duplicate | Flag | PURGE
Snap Inc Software Developer Arrays - 2of 2 votes
AnswersGiven an undirected graph and a node, modify the graph into a directed graph such that, any path leads to one particular node.
- neer.1304 December 25, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 2of 2 votes
AnswersModel a restaurant reservation system, where staff can a reservation, pull up, cancel reservations. The reservation system is very simple local to just one terminal at the restaurant not connected to network.
- soumi July 27, 2015 in United States for Echo| Report Duplicate | Flag | PURGE
Amazon Senior Software Development Engineer Object Oriented Design - 2of 2 votes
Answershow would you design a microwave for the blind?
- harushimo July 24, 2015 in United States| Report Duplicate | Flag | PURGE
Google Program Manager design - 2of 2 votes
AnswersA single-elimination tournament with 64 teams. Before the tournament, fans construct fantasy brackets for their tournament predications. Design a data structure for storing fan brackets and algorithm to score their brackets against a winning bracket. Assume we will then need to quickly score a player’s predictions (1 point per successful round prediction) and your solution should be optimal enough to handle millions of fan brackets with minimal data.
- DVD July 15, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Data Structures - 2of 2 votes
AnswersShuffle a given array such that each position is equally likely.
- xmlprgrm June 15, 2015 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven a lane where there are various houses each containing a fixed amount of gold. Now a robber has to rob the houses such that when he robs a house the adjacent one cannot be robbed.Calculate the maximum amount of gold collected by him.
- kri1311 May 27, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 2of 2 votes
AnswersDesign a robot that will take your order and make sandwiches for you.
- JSDUDE December 12, 2014 in United States for AWS Infrastructure Planning, Analysis and Optimization
Once I was done with this, I was supposed to extend it to have multiple robots doing this job like an assembly line handling multiple sandwiches and other edible items
Once I handled that, he asked me to create a web service for this that will handle online ordering. He also wanted me to implement fulfillment centers| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 2of 2 votes
AnswersDesign a vending machine
- JSDUDE October 27, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Object Oriented Design - 2of 2 votes
AnswersDesign a parking lot system where you need to provide a token with the parking space number on it to each new entry for the space closest to the entrance.
- duskan February 13, 2014 in United States for Sales
When someone leave you need update this space as empty.
What data structures will you use to perform the closest empty space tracking, plus finding what all spaces are occupied at a give time.| Report Duplicate | Flag | PURGE
Apple Software Engineer / Developer Algorithm - 2of 2 votes
AnswersI was asked a question in an interview.
- Park February 06, 2014 in India
On an office floor , there are e entities - Walls , Cubicles , Coffee Rooms.
In what data structure we should store this design that when a new member joins the company , the cubicle number which is empty and next closest to any coffee room should be assigned to it.
Basically , data structure DS.pop() should return that cubicle number in the most efficient way.
A Person can walk through cubicles to reach a coffee room but not through walls.| Report Duplicate | Flag | PURGE
Motorola Software Engineer / Developer Data Structures - 2of 2 votes
AnswersWrite a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function
- Madan December 18, 2013 in United States| Report Duplicate | Flag | PURGE
Google SDE-2 - 2of 2 votes
AnswersGiven a matrix M with (with positive or negative numbers) find the largest sum S of any sub-matrix of M.
- Omar.Enayet November 02, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 2of 2 votes
Answers1. Which of the following regular expressions denotes zero or more instances of an a or b?
- !@# June 07, 2013 in India
a) a l b
b) (ab)*
c) (a l b)*
d) a* l b| Report Duplicate | Flag | PURGE
Algorithm - 2of 2 votes
AnswersDesign the Facebook newsfeed for an Android app. The actual design would be very complex so you may limit your solution to only status updates and photo posts. Keep your answer broad rather than deep since it would need to fit in a 45-minute interview.
- Barry Fruitman March 20, 2013 in United States
Normally you would need to ask the interviewer a lot of questions but since that is not possible here, state your assumptions.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Android - 2of 2 votes
AnswersHow would you tell whether a graph has a node with n degree??
- shivamdurani220 October 11, 2018 in United States
tell your approach| Report Duplicate | Flag | PURGE
Google SDE-2 - 2of 2 votes
AnswersWrite a program to return nearest elements from a binary search tree for input element.
- mh4wt@virginia.edu December 23, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Java