SDE1 Interview Questions
- 0of 0 votes
AnswersSingle Initialization :
- JSDUDE May 04, 2013 in United States
Global variable x, initialized to 0.
Implement a function that can be called by multiple threads simultaneously or sequentially.
The value of x should be set to the current time only once. If it is already set, the value shouldn't be updated.
Make sure that the function doesn't become a bottleneck| Report Duplicate | Flag | PURGE
Microsoft SDE1 Threads - 0of 0 votes
AnswersGiven a BT and 2 nodes, find LowestCommonAncestor
- JSDUDE May 04, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 2of 2 votes
AnswersFind the Max sum subsequence in array
- JSDUDE May 04, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 Arrays - 0of 0 votes
AnswerThere is a HealthMonitor and two Servers (Primary and Secondary), all connected to one and another.
- JSDUDE May 04, 2013 in United States
The HealthMonitor keeps pinging both the servers at specific time intervals and waits for their response for a time-out period after the request has been sent.
The server responds with a health status of itself and of its neighbor (meaning Primary responsds: OK; NEIGHBOR_OK)
Implement the server's code to send and receive responses and then take action based on response.| Report Duplicate | Flag | PURGE
Amazon SDE1 Threads - 3of 3 votes
AnswersWrite a class that will have following functions:
- JSDUDE May 04, 2013 in United States
long CheckOut()
CheckIn(long)
Range of values is 1 to LONG_MAX
At any given point in time checkout should return the minimum available LONG number
Checkin can return the value back
No need to check for border conditions (e.g. check out when all values are exhausted)
Implement:
1. long checkout()
2. void checkIn(long input)| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersWrite a class For Contacts on a device
- JSDUDE May 04, 2013 in United States
Implementing Search a contact was the biggest problem I faced (because search should potentially search: FirstName, LastName, Address, PH#, Email etc)| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 0of 0 votes
AnswerWrite a class for a parking garage:
- JSDUDE May 04, 2013 in United States
One level
One entry point
No membership or payments required
Handles multiple types of cars| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 0of 0 votes
AnswersImplement:
1. a search that will return all the strings that match a sub-string
2. an insert into this datastructure
- JSDUDE May 04, 2013 in United StatesClass { Insert (string str){}; List<strings> Predictions(string subString){}; }
| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - 0of 0 votes
AnswersImplement an iterator for a Binary tree. It should have the following things:
- JSDUDE May 04, 2013 in United States
1. bool HasNext()
2. <T> Next()
It should be an in-order traversal.| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - 0of 0 votes
AnswersAdding Very Large Numbers. Write clean code for it. please check all corner cases..
- nr May 02, 2013 in United States for web service
Number can be really really large| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersFind the 3rd closest element in a bst.You will be given a pointer to root and a value within the tree against which the closest has to be figured out. (closeness is in terms of value, not by distance ) and then follow up qn: for finding the kth closest in a bst.
- seth May 02, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersGiven a BST find Ceiling value of given key
8 6 12 2 4 11 14
key = 8 return 11
- JSDUDE April 27, 2013 in United States
key = 1 return 2
key = 16 return Null
Iteration and Recursion both| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 1of 1 vote
AnswersQ:
Given a binary tree with nodes that have left, right pointers pointing to the left and right children respoectively. It also has a neighbor pointer that currently Points to null.
Write a function to make it point to its neighbor.
E.g1 2 3 4 5 6 7
1.sibling should point to null
- JSDUDE April 27, 2013 in United States
2.sibling should point to 3
3.sibling should point to null
4.sibling should point to 5
5.sibling should point to 6
6.sibling should point to 7
7.sibling should point to null
Iteration and Recursion both| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 1of 1 vote
Answers4 men- each can cross a bridge in 1,3, 7, and 10 min.
- Abhinav April 27, 2013 in United States for MS office
Only 2 people can walk the bridge at a time. How many min. minutes would they take to cross the bridge.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Brain Teasers - 0of 0 votes
AnswersInput is given a binarytree and out is sum of the all the children data and its node data .
- phaniteja.24 April 27, 2013 in India
Eg:
1 28
2 3 11 16
4 5 6 7 4 5 6 7| Report Duplicate | Flag | PURGE
Amazon SDE1 - -1of 1 vote
AnswersGiven a sorted array consisting 0's and 1's. find the index of first '1'. write a complete program which takes less time complexity. and test all boundary conditions also.
- phaniteja.24 April 27, 2013 in India
Eg: If given array is 0,0,0,0,0,0,1,1,1,1 the out put should be 6.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 3 votes
AnswersCode to create a file system.... Have classes like directory, file and all
- nr April 21, 2013 in United States for Kindle
please write the full code| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
AnswersIn a BST, I want to replace all nodes with value which is the sum of all the nodes which are greater than equal to the current node.
- Abhishek Shrivastava April 20, 2013 in United States
5
2 10
Output -->
15
17 10| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersYou are given a BST, and min, max elements. Your task is to trim this BST so that it contains the elements between the min and the max elements.
For example, given the mix and max elements [5, 13] and the tree below, you would return the output below.8 3 10 1 6 14 4 7 13
output should be :--->
- Abhishek Shrivastava April 20, 2013 in United States8 6 10 7 13
| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersFinding border of a binary tree.Given a Binary tree print all the nodes that form the boundary.
- mrunalishah.cool April 20, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
Answershow do you handle your thread, to avoid dead lock and efficient(generally question)
- xuwanglong1988 April 19, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answerswhat is Materialized view, is any different from View.
- xuwanglong1988 April 19, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Database - 0of 0 votes
AnswersGiven an array of integers, find all sub-arrays whose elements sum zero.
- ANONU April 16, 2013 in India
1.-1,4,-4 has 3 such arrays 1 to -1, 1 to -4 and 4 to -4| Report Duplicate | Flag | PURGE
Microsoft SDE1 - 0of 0 votes
AnswersGiven a directed acyclic graph.How to represent it in the relational database for efficient retrieval of all the children nodes and all the parents of any node.(ex a->b here b is child of a and a is parent of b)
- ANONU April 14, 2013 in India| Report Duplicate | Flag | PURGE
Google SDE1 - 1of 1 vote
AnswersGiven a string.Find the longest substring in it such that the substring contains only 2 unique characters.Ex- aabbcbbbadef Ans-bbcbbb
- ANONU April 14, 2013 in India| Report Duplicate | Flag | PURGE
Google SDE1 - 1of 1 vote
AnswersIn a party there are n different-flavored cakes of volume V1, V2, V3 ... Vn each. Need to divide them into K people present in the party such that
- ANONU April 14, 2013 in India
- Each member of party gets equal volume of cake (say V, which is the solution we are looking for)
- A given member should get a cake of single flavour only i.e. You cannot distribute parts of different flavored cakes to same member.
- Minimum volume of cake gets wasted after distribution so that means a maximum distribution policy| Report Duplicate | Flag | PURGE
Google SDE1 - 0of 0 votes
AnswersData Structure for node of linked list
- kumar.prince6 April 11, 2013 in India for IDC
Find the nth node form end of a linked list and also write test case
i have given solution with o(n) after that they asked to me how to break the my algorithm| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm