SDE1 Interview Questions
- 0of 0 votes
AnswersGiven function List friendList(Person p) which will give all freinds list of that person. Write a function such that printConnectedLeastFriends(Person A, Person B); if none of the friends found connected print "NONE";
- MrA July 07, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersGiven a word consisting of letters, different words can be formed using all the letters in the word. Find the rank of input word in sorted list of all possible words.
- engineer July 07, 2013 in United States
Eg.
ABAB = 2
QUESTION = 24572
Program should use no more than 1GB memory and run within 500 milliseconds. Maximum input length = 25 and input word will contain atleast 2 different letters.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersString [] [] matrix = {{"A","N", "L", "Y", "S"},{"I", "S", "D", "E", "S"},{"I", "G", "N", "D", "E"}};
- gohilumesh July 05, 2013 in United States
// 2. Given a word "DES"
// 3. Write a program to find the occurences of this word "DES". Letters must be next to each other in the matric.
// 4. "Next" means: left, right, up, down, left down, right down, upper left, upper right
// 5.. For example: S at (1,1): A, N, L, D, N, G, I, I are next to S at (1,1)
Required output
// // D - [1, 2], E - [1, 3], S- [1, 4]
// D - [1, 2], E - [1, 3], S- [0, 4]
// D - [2, 3], E - [2, 4], S - [1, 4]
// D - [2, 3], E - [1, 3], S - [0, 4]
// D - [2, 3], E - [1, 3], S - [1, 4]| Report Duplicate | Flag | PURGE
Amazon SDE1 Matrix - 2of 2 votes
AnswersHow can we implement spell checker.
- rapirapp July 04, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Data Structures - 1of 1 vote
AnswersDifference between concurrency and parallelism
- JSDUDE June 27, 2013 in United States
How has threading helped concurrency and parallelism?| Report Duplicate | Flag | PURGE
Ebay SDE1 Threads - 1of 1 vote
AnswerFormula for nth PI is (-1^n)/(2n+1). Write an efficient way to calculate this.
- JSDUDE June 27, 2013 in United States
After i wrote a recursive and iterative solution, she wanted a faster solution. So i went to threading.
Eventually she said that if the value of n is a million and you can't have million threads how will you distribute:
Problem is as n increases the above computation becomes time consuming and hence cannot be simply split in ranges.
She hinted me towards: Queue of jobs, threads picking jobs and en-queuing the work| Report Duplicate | Flag | PURGE
Ebay SDE1 Math & Computation Threads - 0of 0 votes
AnswersWrite a function to calculate the nth prime number:
- JSDUDE June 27, 2013 in United States
N = 0; Prime#: 2
N=1; Prim#: 3
What is the complexity of this alogirthm| Report Duplicate | Flag | PURGE
Ebay SDE1 Math & Computation - 0of 0 votes
AnswersYou are given a 2D array that is your sea. It has more than one ships which don't overlap each other. All ships are not necessarily of the same size.
- JSDUDE June 27, 2013 in United States
You are to improve on performance and space is no concern.
Write a program that takes in two co-ordinates:
If the attack co-ordinates did not have a ship, print "Missed"
If the attack co-ordinates have a ship, print "Attacked Ship <Name>"
If the attack co-ordinates have a the same part of the attacked ship, print "Already Attacked"
If the last piece of the un-attacked ship was attacked print: "Ship sunk".| Report Duplicate | Flag | PURGE
Ebay SDE1 Coding Data Structures - 0of 0 votes
AnswersGiven a binary tree with each node having a pointer to its parent, Write a function that can find the immediate right neighbor of a given node. Don't use BFS.
- JSDUDE June 27, 2013 in United States
Node* RightNeighbor(Node* node)
Note: Root of the tree is not given| Report Duplicate | Flag | PURGE
Ebay SDE1 Trees and Graphs - 0of 0 votes
AnswersThere is a file on a server. There are 3 access levels to this file: 1. Read\Write 2 Read 3. No access.
- JSDUDE June 27, 2013 in United States
A person can: 1. Copy a file. 2. Edit it on the server 3. Overwrite the existing file on the server
Write all the test cases for this scenario| Report Duplicate | Flag | PURGE
Ebay SDE1 test - 0of 0 votes
AnswersDesign a tree, in which a node can have unlimited children and write a code to print each level in separate level.
- grave June 27, 2013 in India
(As the number of children is large we cant store them in queue.Can we do it without extra space ?)| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersFind the largest k elements from a large file?
- grave June 27, 2013 in India
You dont have RAM to store even k elements.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersGiven an array of positive integers, find the max no that can be formed by any permutation of the arrangement.
- Vin June 26, 2013 in India
input {21,9,23}, output = 92321| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersGiven a string dind the largest substring which is palindrome.
- anag June 26, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 5of 5 votes
Answers100 doors are closed , In first pass i open all of them , in 2nd pass i toggle every 2nd door , in 3rd pass i toggle every 3rd door , i continue it till 100th pass .. find all the doors that will remain open after 100 passes.
- anag June 26, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Brain Teasers - 5of 5 votes
Answersfind the sum of all 4 digit numbers formed from 1 , 2, 3, 4 whithout rep .
- anag June 26, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Brain Teasers - 1of 1 vote
AnswersTwo files containing large number, one in each. You have only fopen(), int read(fp), fclose(), fwrite(). Add these two numbers and write in third file with the help of given functions only.
- grave June 23, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm C# C++ Coding Data Structures - 0of 0 votes
Answersswap kth element from the beginning and kth element from the end of linked list.
- anonymous June 21, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
Answersprint a decimal number in binary form. eg: number=10 or 2.22 or 0.876 ....
- anonymous June 21, 2013 in India
required to print only four number after decimal point| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
Answersfind all elements in the loop of an linked list....( linked list may or may not have loop)
- anonymous June 21, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
AnswersGiven a binary tree, for each node in the tree find the nodes with value greater than or equal to current node and sum them with the value of the current node. replace the node value with the above calculated sum....
- anonymous June 21, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 1of 1 vote
Answersgiven an array of number. find the largest possible sum of numbers in the array.
- anonymous June 21, 2013 in India
Condition: no two elements should be picked consecutively and position of elements in the array should not be changed..| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
Answersgiven a binary tree in which a node can have two childs or no child. All the leaf nodes are represented as 'L' and parent nodes are represented as 'P'.
- anonymous June 21, 2013 in India
Given the preorder of the tree (string eg : PPPLLP....) find the depth of the tree.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
AnswersIs it possible to compare two Binary trees for equality in iterative manner without using extra space?
- Algorithmist June 17, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersGiven a list of test results (each with a test date, Student ID, and the student’s Score), return the Final Score for each student. A student’s Final Score is calculated as the average of his/her 5 highest test scores. You can assume each student has at least 5 test scores.
You may use the JDK or the standard template library. The solution will be evaluated on correctness, runtime complexity (big-O), and adherence to coding best practices. A complete answer will include the following:
Document your assumptions
Explain your approach and how you intend to solve the problem
Provide code comments where applicable
Explain the big-O run time complexity of your solution. Justify your answer.
Identify any additional data structures you used and justify why you used them.
Only provide your best answer to each part of the question.
Use the following skeleton for your solutions.
Java:
- aopencv June 16, 2013 in United Statesclass TestResult { int studentId; String testDate; int testScore; } public class FinalScoreQuestion { Map <Integer, Double> calculateFinalScores (List<TestResult> results) { }
| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Java Problem Solving Sorting - 2of 2 votes
AnswersDesign Elevator system. And then write an algorithm for that Design such that, the user request should be completed in logN time in a N story building with M elevators,
- fbrubacher June 16, 2013 in United States for Search| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersWrite a program to remove duplicates from array of prime numbers.
- onlinesoumitra June 14, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm