SDE-2 Interview Questions
- 0of 0 votes
AnswerPhoneBook search. Given input phone book - John, JohnDavis, Ted, JackMay
- LaterG June 11, 2017 in United States
Searching J should return John, JohnDavis and JackMay
Seaching JD should return JohnDavis| Report Duplicate | Flag | PURGE
SDE-2 - -1of 1 vote
AnswersEnhancements to schema by adding another table lot
- krish June 09, 2017 in United States
SELECT *
FROM Amazon_lot p,
amazon_vehicles v
WHERE p.lotid= 1
AND p.lotid = v.lotid
AND v.vehicleid = 1;
-- was struck for a moment, Interviewer helped me with hint
SELECT count(1)
FROM amazon_residents r,
Amazon_lot l,
amazon_vehicles v
WHERE r.residentid = l.residentid
AND l.lotid = v.lotid
AND r.residentid = v.residentid
AND (v.vehicleid = 1
OR v.lotid = 2);| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersSQL Questions & Answers ,and followup questions
- krish June 09, 2017 in United States
given schema
Tables:
Residents:
resident_ID (num)
Apartment Number
Name
...etc
Vehicles:
vehicle_ID (num)
(FK): Resident_ID (num)
License Plate
Vehicle Size ("small", "large", "motorcycle"...)
Get all the residents who has vehicle size large
SELECT *
FROM amazon_residents res
WHERE EXISTS
( SELECT 1
FROM amazon_vehicles veh
WHERE veh.residentid = res.residentid
AND veh.type = 'large' );| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersGiven items as Shirt, Trouser, Shoes, Tie, Belt, Shocks, and dependencies as -
- codechamp June 06, 2017 in India
Tie can be worn after Shirt
Belt can be worn after Shirt and Trouser
Shocks can be worn after Trouser
Shoes can be worn after Shocks
Find various orders in which the activity of wearing clothes can be completed.| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersFind all the abbreviations of string:
- ashishsaraswat.iips June 06, 2017 in India for AdsWorld
eg
ABC
SOME Valid abbreviations are :
1BC
2C
3
A1C
AB1
A2
NOT VALID
11C(two numbers cannot occur continuously)| Report Duplicate | Flag | PURGE
Google SDE-2 - 0of 0 votes
AnswersGiven a method
- ashishsaraswat.iips June 06, 2017 in India for AdsWorld
public int getOccurence(int x,int y);
where y is always a single digit number.
So find the number of occurrences of number y in the range x
E.g.
if x=25,y=2
function should return 9(as 22 contains two occurrences of 2) - 2,12,20,21,22,23,24,25| Report Duplicate | Flag | PURGE
Google SDE-2 - 0of 0 votes
AnswersGiven a very large file of 10GB containing product price . Sort the file of product if memory available is 1 GB
- ashishsaraswat.iips June 06, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersIf you find your web-services are slow, So where you start debugging and what could be the reasons for performance slow down.
- azambhrgn May 25, 2017 in India| Report Duplicate | Flag | PURGE
Tivo SDE-2 Debugging - 0of 0 votes
AnswersThe number of valid combinations of a strings for given input array a[], where a=>1, z => 26, and 0 <= a[i] <= 9
- nelly2k May 19, 2017 in United States
{1,1,1} => {aaa, ak, ka} => 3
{1,1,0} => {aj} => 1| Report Duplicate | Flag | PURGE
Facebook SDE-2 Algorithm - 0of 0 votes
AnswersProducts are identified by alphanumeric codes. Each code is stored as a string. We have three types of products:high priority, medium priority, and low priority. Given an array of product codes, sort the array so that the highest priority products come at the beginning of the array, the medium priority products come in the middle, and the low priority customers come at the end. Within a priority group, order does not matter. You are given a priority function which, given a product code, returns 1 for high, 2 for medium and 3 for low. This array may contain a large number of product codes, so do your best to minimize additional storage.
- job_seeker May 17, 2017 in United States| Report Duplicate | Flag | PURGE
SDE-2 Data Structures - 0of 0 votes
AnswersProducts are identified by alphanumeric codes. Each code is stored as a string. We have three types of products:high priority, medium priority, and low priority. Given an array of product codes, sort the array so that the highest priority products come at the beginning of the array, the medium priority products come in the middle, and the low priority customers come at the end. Within a priority group, order does not matter. You are given a priority function which, given a product code, returns 1 for high, 2 for medium and 3 for low. This array may contain a large number of product codes, so do your best to minimize additional storage.
- job_seeker May 17, 2017 in United States| Report Duplicate | Flag | PURGE
SDE-2 Data Structures - 0of 0 votes
AnswerDesign entity(model) structure of a file systems. You don't have to write any interfaces, just various models and their properties.
- sonesh May 11, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 design - 0of 0 votes
AnswersYou have to desing a system for a shop kepper to keep his/her inventory managed. He/she have furniture at the begining, but he may add more items to it. His/her furnitures are wood char, wood table, steel chair, etc.
- sonesh May 11, 2017 in United States
Each furniture have one property, a boolean one, called isChildSafe.
Later, he said, what if the shopkeeper wants to add new type of items, such as phone or may be something else, and he/she might also wants to add two new properties, such as isFireSafe, isWaterSafe etc.
How would you design extend to these types.| Report Duplicate | Flag | PURGE
Amazon SDE-2 design - 0of 0 votes
AnswersYou have to design a job scheduler. The job schedular should be able to accept all kind of jobs, small or long running. Multiple systems might be adding jobs to it and multiple systems should be able to execute jobs simultaneously.
- sonesh May 11, 2017 in United States
Please list down the components and data flows between them, what kind of interfaces you will be having, what kind of retry logic you will be providing, storage and middle tier design was also asked.| Report Duplicate | Flag | PURGE
Amazon SDE-2 design - 4of 4 votes
AnswersYou are given set of strings, You have return anagrams subsets from it. An anagram set is that one where every string is an anagram of another string. If the subset contains only one string, don't include that in the result.
- sonesh May 11, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm String Manipulation - 0of 0 votes
AnswersYou are given a NxN boolean matrix, where matrix(i,j) will be one if 'i' is a parent of 'j' in a tree, otherwise, it is zero.
- sonesh May 11, 2017 in United States
Construct this tree.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm Trees and Graphs - 0of 0 votes
AnswerDesign/Implement an LRU cache so that Read/Write/Find operation only takes constant time.
- sonesh May 11, 2017 in United States
Now, Let's say, we will be considering the frequency as well. It means to keep the most used processes and in a case of the tie, use lease recently used to remove an element.
Now, as this new algorithm can cause many hits, or no new process will come to the cache if the last process of the cache has two hits., What can you do to prevent this, and how would you implement that.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm design - 1of 1 vote
AnswersThere is a cluster of servers. In this cluster some group of servers are running application A, some group are running B, etc. Each application server produces huge logs and the log file sizes run into GBs. Each minute there are millions of log entries.
- Curious May 09, 2017 in India
You need to design a system that allows you to:
1. Specify the name of the application whose logs you want to search.
2. Search any text that the log message may contain.
3. Search within a time stamp range.
4. Search within the specified log level(s).
The system should be real-time.| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 1of 1 vote
AnswersIt is presidential election time.Mr X is fighting for the president.The country has N number of cities.
- hitansu166 May 04, 2017 in India for Aelxa
The cities are divided into developed & developing city on basis of a developemt index A.
If A is 1, then the city is developed. If A is 0, then the city is developing.
A close source to Mr X told that all the people from developing cities will vote for him while people
from only k number of developed cities will vote for him.
Find out the no of maximum vote in favour & minimum vote in against Mr X will get.
Input
------
10 3
0 12
0 6
0 7
1 8
1 12
1 17
1 20
1 22
1 5
1 6
First 2 line gives no of cities N= 10 & number of developed cities vote for Mr X k= 3
Next 10 lines give the development index A & number of people in the city
For example in the first line A= 0, no of people= 12| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 1of 1 vote
AnswersConstructing City
- hitansu166 May 03, 2017 in India for Alexa
In a country the cities are connected through roads of 3 types 1, 2, 3.
All the roads are bi-directional. The roads of a city has some restriction.
Road of type 3: both men and women can walk
Road of type 2: only women can walk
Road of type 1: only men can walk
Now the govt. wants to remove extra roads.But the cities should be connected for both men & women.
Connected means one should able to reach from one city to other & vice-versa.
Find out the maximum no of roads can be removed so that the cities can be accessible to both men & women.
Input:
5 5
1 2 3
2 3 3
3 4 3
5 3 2
5 4 1
First line gives no of cities & no of roads. Next each 5 lines gives city source, city destination, type for a roads.
5: no of cities 5: no of roads
1: city-1 2: city-2 3: type 3 road
o/p: 2| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersWrite a program which takes input a sorted array and positive number and updates the array so that if x appears m times in array then it appears exactly min(2,m) times in array. the update should be performed in one pass with no additional memory
- ashishsaraswat.iips April 17, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Arrays - 0of 0 votes
AnswersDesign a system to monitor services (like when they were down/ CPU time) etc.
- usri April 10, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswerDesign a system for dashboard that effectively shows almost real time data.
- usri April 10, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 2of 2 votes
AnswersGiven a sorted array with "n" elements, distributed them into "k" nearly equally weighing buckets.
- reddy88 April 02, 2017 in United States
Space is not constraint.
Ex: [1,3,6,9,10]
bucket size: 3
output:[10],[9,1],[3,6]| Report Duplicate | Flag | PURGE
Amazon SDE-2 Dynamic Programming - 3of 3 votes
AnswersDesign backend system for bookMyShow.com like system which supports below use cases:
- Priyanka March 29, 2017 in India
1) When user selects cities, list of cities is displayed.
2) When user selects city, movie list is displayed.
3) When user selects movie, list of theatre is displayed.
4) When user selects theatre, show timing is displayed.
5) When show timing is selected, user is asked for no of seats that he wants to book
6) When user selects no of seats, seats are displayed to choose from.
7) When user selects seats, then total price is displayed.
8) When total price is selected, then user is directed to payment gateway and payment is done and on payment success, ticket is mailed to him.
More questions on how can we scale the system, and handle concurrent users request for same seat etc.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 2of 2 votes
AnswerDesign a movie ticket booking system like bookmyshow.com
- neer.1304 March 29, 2017 in United States
Follow-up question -
1) How do you handle issues like scalability, concurrency, fault-tolerance etc.
2) Show movie theaters near to user where movie is playing and seats are available
3) Design database. What kind of DB would you use SQL or No-SQL
4) In real time how would you show which seats are booked which are free
5) If theaters do not have any api for fetching information then what can we do about it.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Software Design