SDE-2 Interview Questions
- 0of 0 votes
AnswerI need to create a database that have five columns each entry is such that there can be repeated tuples in each column(No primary key).There will be no two same entries
- vank February 17, 2017 in United States
There are 5 Methods that needs to be implemented
1. Create() - create the database
2. Add(string a,b,c,d,e) - Add single entries with 5 tuples(all strings)
3. Update (culumntype1, columnvalue1,culumntype2, columnvalue2)
- each entry having culumntype1 = columnvalue1 will be updated by columntype2=columnvalue2 and return total such eantries.
4. Delete (culumntype1, columnvalue1)
- each entry having culumntype1 = columnvalue1 will be deleted.and return total such eantries.
5. Search(culumntype1, columnvalue1)
- Search each entry having culumntype1 = columnvalue1 and return total such eantries.
How to implement in best possible way such that there can be 50,000 such entries?| Report Duplicate | Flag | PURGE
Google SDE-2 - 1of 1 vote
Answershow to create an object on the stack.
- Giri February 10, 2017 in India
and also make sure that only 5 objects are created for the class| Report Duplicate | Flag | PURGE
Oracle SDE-2 C++ - 0of 0 votes
AnswersDesign Amazon Recommendations Feature. Focus on designing how would you store and make it accessible fast? What would be class design like for the class which would provide list of products which people bought similar to a given product? How would you test that class?
- Anonymous February 07, 2017| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures Database Object Oriented Design - 0of 0 votes
AnswersGive a large multi MB byte file in memory, a system handles delete requests for segments typically of the order of bytes. The system has a constraint that individual purge requests of byte segments are expensive, so that the no. of purges are a minimum.
- naveentmani January 21, 2017 in United States for AWS
Eg. a 5 MB file receives delete requests for offsets (1, 100), (250, 550),(1000, 1200), (400, 600), (800, 900), (1100, 1150)
Effective delete requests - (1, 100) , (250, 600), (800, 900), (1000, 1200)
The users of the system always go by the absolute byte ordering of the file. Eg. if byte 1 is deleted, the users of the system will reference the actual byte 2 as byte 2.
What data structure would you use to store these intervals such that the following operations are efficient 1. Looking up an interval 2. Inserting a new interval that has no overlap with existing ones 3. Inserting a new interval that has partial overlaps with existing intervals. This would involve collapsing the existing intervals with the new interval to form a single large interval. Eg. Interval cache: {(1, 100), (250, 550), (1000, 1200)} , new interval : (400, 700) -> Interval cache: {(1,100), (250, 700), (1000, 1200)}| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 0of 0 votes
AnswersGiven an mXn Sorted matrix and a value X. Every row is sorted and first number of every row is greater than last number of previous row Find the value X in most efficient way.
- neelabhsingh January 18, 2017 in India for Hyderabad| Report Duplicate | Flag | PURGE
Amazon SDE-2 Matrix - 2of 2 votes
AnswersGiven a Binary tree and value X. Find X in the tree and return its parent
- neelabhsingh January 18, 2017 in India for Hyderabad
X:
10
4 3
5 7 9 8
If X = 7, return 4| Report Duplicate | Flag | PURGE
Amazon SDE-2 Trees and Graphs - 0of 0 votes
AnswersGiven a list of list of positive integers, find all pairs of list which are having more than 3 elements overlapping.
- rohitatiit January 10, 2017 in India
What is the complexity.| Report Duplicate | Flag | PURGE
Practo SDE-2 Algorithm - 2of 2 votes
AnswersDesign OO food delivery app catering to use cases -
- neer.1304 December 06, 2016 in United States
1) User can search different restaurant
2) User can select a restaurant
3) User sees a menu
4) Restaurant can change the menu any time
5) User adds an item from menu
6) User orders the food
7) User can track the order in real time
8) User can cancel the order
9) User pays for the order| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 0of 0 votes
AnswersDesign food delivery app (OO design). Cater to use cases like search for different restaurants, selecting a restaurant, select an item from menu, menu can be updated in real time by restaurant, order the food, customer keeps track of the order in real time, payment for the order, cancel the order etc.
- neer.1304 December 06, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 0of 0 votes
AnswersDesign Uber low level OO design. Cater to use cases like search for a ride, different category of rides, select a ride, registration for a user and driver, paying for ride etc.
- neer.1304 December 06, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 1of 1 vote
AnswersGiven a dictionary and an char array print all the valid words that are possible using char from the array.
- neer.1304 December 02, 2016 in United States
Ex- char[] arr = {'e','o','b', 'a','m','g', 'l'}
Dict - {"go","bat","me","eat","goal", "boy", "run"}
Print - go, me, goal.
We can pre-compute as much we want but the query time must be optimal.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven input which is vector of log entries of some online system each entry is something like (user_name, login_time, logout_time), come up with an algorithm with outputs number of users logged in the system at each time slot in the input, output should contain only the time slot which are in the input. For the example given below output should contain timeslots
- ann November 22, 2016 in United States
[(1.2, 1), (3.1, 2), (4.5, 1), (6.7, 0), (8.9, 1), (10.3,0)]
/*
[
("Jane", 1.2, 4.5),
("Jin", 3.1, 6.7),
("June", 8.9, 10.3)
]
=>
[(1.2, 1), (3.1, 2), (4.5, 1), (6.7, 0), (8.9, 1), (10.3, 0)]
*/| Report Duplicate | Flag | PURGE
Uber SDE-2 - 0of 2 votes
AnswersHow would you design Amazon Lockers?
- teli.vaibhav October 30, 2016 in United States
Amazon Lockers - Customers can use these lockers to have their products delivered. These lockers are physically available to customers at the same or several nearby zip codes.| Report Duplicate | Flag | PURGE
Amazon SDE-2 design - 0of 0 votes
AnswersThe amazon site was working just fine until yesterday. But in the past 24 hours processing the customer orders is taking a really long time.
- teli.vaibhav October 30, 2016 in United States
How would you debug and fix the issue?
When I asked if anything had changed in the past 24 hours, I was told several new products had been added after which the performance issues were noticed.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Debugging - 3of 3 votes
AnswersGiven the root of a Binary Tree along with two integer values. Assume that both integers are present in the tree.
- teli.vaibhav October 30, 2016 in United States
Find the LCA (Least Common Ancestor) of the two nodes with values of the given integers.
2 pass solution is easy. You must solve this in a single pass.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
AnswersYou are given 2 lists -
List 1: List<Demand> is a list of Demand objects.
List 2: List<Supply> is a list of Supply objects.
Return a result fulfillment List<Demand,List<Supply>>.
This means each demand could be satisfied by more than one supplies.class Demand { Date startDate; Date expirationDate; int quantity; } class Supply { Date startDate; Date expirationDate; int quantity; }
The Demand and Supply refers to that of groceries. You must map supplies to a demand only if the supply still has at least 3 days remaining to its expiration before the demand can be fulfilled.
- teli.vaibhav October 30, 2016 in United States
A demand is said to be fulfilled 24 hours after all demands have been mapped to correspondingly available supplies.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
AnswersGiven a string with only parenthesis. Check if the string is balanced.
- teli.vaibhav October 30, 2016 in United States
ex -
1) "<({()})[]> is balanced
2) "<({([)})[]> is not balanced| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - -1of 1 vote
AnswerWrite code for the partition subroutine in Quicksort.
- teli.vaibhav October 30, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
AnswerHow would you Design a HashTable?
- teli.vaibhav October 30, 2016 in United States
In what ways would you attempt to address collisions?| Report Duplicate | Flag | PURGE
Amazon SDE-2 design - 4of 4 votes
AnswersGiven that an external service gives a list of credit cards that have become fraud, design a fraud management system for a shopping website for bookings with fraud credit cards
- mesmerizing.memories123 October 14, 2016| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 0of 2 votes
AnswersGiven a list of shops each of which have a list of toys with their prices and max number of children who can play with it at a time. Output the a list of best possible toy option from each shop given the number of children who are shopping.
- mesmerizing.memories123 October 14, 2016 in India
ToyShopping
{
getListOfBestToysFromEachShop(List<Shop> shops);
}
Shop
{
int id,
List<Toy> listOfToys;
}
Toy
{
int toyId;
int shopId;
int price;
int maxChildren; //max number of children who can play with this toy
}| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersDesign the classes for a Battleship Game. Write the attack function.
- Ray October 04, 2016| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 14of 14 votes
AnswersWrite a program to check whether it is a valid binary tree or not. Check all test cases (e.g. No left Node case).
- Neelavan October 02, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswerGiven (a,b) can you reach to (c,d) if a and b can move either (a+b,b) or (a,a+b). Example a =1, b=4,c=5,d=9 then (1,4) -> (5,4) -> (5,9)
- karan.r.shah92 September 20, 2016 in United States| Report Duplicate | Flag | PURGE
A9 SDE-2 - 2of 2 votes
AnswersDesign a logging system. The system contains multiple application servers which are logging the information to file system. In this scenario, we want to check and alarm in case an exception is thrown in any of the servers. We want a system that checks for appearance of specific words, "Error", "Exception", "Disk Full" etc. in the logs of any of the servers. How would you design this system?
- jay September 17, 2016 in India
What if we want to scale the system in future?| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 0of 0 votes
AnswerWe need a functionality to block an user who makes more than 10 requests in last 5 minutes. You need to implement the following function.
- rayasamharish September 14, 2016 in United States
{{
boolean block_user(int user_id)
{
//TODO: return true in case u want to block user
}
}}| Report Duplicate | Flag | PURGE
anonymous SDE-2 Algorithm - 0of 0 votes
Answersobject oriented design for robot vacuum cleaner.
- akash.umang August 30, 2016 in United States
write use cases, draw class diagram and interfaces
between them.| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 1of 1 vote
AnswersDesign a deck of cards that can be used for different card game applications.
- gurunathchoukekar August 17, 2016 in United States for AWS
Please code out what you would need for the deck class and a card class.
Implement a deal method.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 0of 0 votes
AnswersDesign a system for searching strings in files present on a fileserver under a directory. there won't be any sub-directories. There could be more than thousand/lakhs files. And the file size could be in GBs. The matching line should be written to a single file. user will execute grep "string"
- maske.s August 10, 2016 in United States
The sub-questions are
1) Design where the application executes on single machine.
2) Design where the application can execute on multiple machine.
3) Where could be the potential bottleneck.
4) What component would be bottleneck if 50 cores and slow disk.
5) What component would be the bottleneck if we 4 cores and fast disks.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 design - 2of 2 votes
AnswersYou have two very large numbers that cannot be stored in any available datatypes. How would you multiply them?
- confused_coder August 08, 2016 in United States
How would you multiply more than two numbers?| Report Duplicate | Flag | PURGE
Microsoft SDE-2