SDE1 Interview Questions
- 0of 0 votes
AnswersGiven a list with duplicate values find the first unique elements in it.
- Vaibhavs April 02, 2014 in United States
for eg: BH BH F AL HJ AL HJ PK
so answer is F| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersGiven a matrix and need to traverse through it last position from first position and the matrix has 0 and 1 if there is 1 we cant proceed ahead.
- Vaibhavs April 02, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersCompare two release version and tell me which is larger
- Vaibhavs April 02, 2014 in United States
eg: 1.0.10 and 1.0.2
1.0.2 is greater
1.2.0 and 2.1.0
2.1.0 is greater| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 3 votes
AnswersYou are given a string which has numbers and letters. Numbers occupy all odd positions and letters even positions. You need to transform this string such that all letters move to front of array, and all numbers at the end.
- andy March 09, 2014 in United States for Google Search
The relative order of the letters and numbers needs to be preserved
I need to do this in O(n) time and O(1) space.
eg: a1b2c3d4 -> abcd1234 , x3y4z6 -> xyz346
Please don't submit your answers if it is not fulfilling the time-space complexity requirements.| Report Duplicate | Flag | PURGE
Google SDE1 - 0of 0 votes
AnswersThere is a file which contains N words. There may be M anagrams in that file, K words on each anagrams. K>=1, M>=1, N>=1. You need to write an algorithm which will create one list for each anagram with k words and group all M lists with one data structure
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 1 vote
AnswersFind your own method to balance an unbalanced binary tree.(you must not use existing methods like AVL, red black or b trees)
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersConvert a sorted integer Array to balanced binary search tree. This is very simple one and I could do it in O(n) time and O(1)extra space
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersGiven 2 sorted linked list , merge them into single sorted list. Change the pointers, don't copy data
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersGiven a read only linked list with next and random pointer , clone the list
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 1 vote
AnswersIt was a design question. You have to design a game. it has different types of monsters and different weapons. hero would shoot monster. each monster would have some initial health. Each weapon would do some predefined damage to monster. when its health gets 0, monster would die/disappear. and there would be multiple levels. based on level, monster and their behavior would change.
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 0of 0 votes
AnswersGiven 2 rectangles , find whether they are overlapping or not.
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - -1of 1 vote
Answersdelete all the nodes from a binary tree that lie on a path whose sum from root to leaf is less than a given value K. Twist was that the node values can be any integer. It may be a negative number.
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersData structure to push, pop and find min element in O(1) time.
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersGiven a linked list like a1-a2-a3-a4-b1-b2-b3-b4. Convert it into a1-b1-a2-b2-a3-b3-a4-b4
- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersThere is a dictionary of billion words and there is one method provided
- pavan February 27, 2014 in India
String getWord(int index); We can give it index and it will return the String on that index .
Now word is given to us we have to find out its index. O(logn) solution was required.| Report Duplicate | Flag | PURGE
Amazon SDE1 String Manipulation - 0of 2 votes
AnswersFrog can jump 1 or 2 steps write the code to find out number of ways to go up to n steps
- pavan February 27, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Dynamic Programming - 0of 0 votes
Answersprogram to pruning a binary tree
- pavan February 27, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 1 vote
AnswersGiven:
- poorna.chandra.akp February 21, 2014 in India for APi Team
R number of Red Cards
B number of Black cards
K
Cards needs to be placed in a circle. Start from a position and for every K moves remove that card And repeat the process until all the cards are eliminated.
Question: Position the cards such that the red cards are completely eliminated before the blacks cards are selected for elimination.| Report Duplicate | Flag | PURGE
Groupon SDE1 - 0of 0 votes
AnswersYou are given an unsorted array of integers that contain duplicate numbers.
- Muhammad Adel February 20, 2014 in Luxembourg
Only one number is duplicated odd number of duplications, other numbers are repeated even number of duplications.
Find this number.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersFind all nodes that are at a distance k from leaf nodes
- anon123 February 16, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersGiven a number N, find the smallest 3 digits number such that product of its digits is equal to N.For example for N=100 , 3 digits number is 455.
- sam February 14, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersGiven a function “f” in which 0 occurs with probability 0.4 and 1 occurs with probability 0.6. Using function “f” deduce a new function “f1” such that both 0 and 1 occurs with probability 0.5
- sam February 14, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Problem Solving - 1of 1 vote
AnswersYou are given a n-ary tree. print all the nodes bottom up except for the right most node at each level.
1 2 3 4 a b c d e
print all except 4 (right most at level 1) and e (right most at level 2)
- sukheshmg February 11, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersYou are given an unsorted integer array consisting of 1's and 0's. You need to rearrange the array with alternating groups of 0's and 1's. The group length is determined by the function f(x)
- sukheshmg February 11, 2014 in India
f(0) = 1
f(1) = 2
f(n) = [square of f(n-1) - square of f(n-2)]
if you run out of either 1's or 0's, then fill the array with whatever is left.
input: 0,0,1,0,1,1,1,0,0,1,0,0,1,1,0,0
output: 0, 1,1, 0,0,0, 1,1,1,1,1, 0,0,0,0,0
f(1) = 1
f(2) = 2
f(3) = sqr(f(2)) - sqr(f(1)) = 3
f(4) = sqr(f(3)) - sqr(f(2)) = 5
f(5) = sqr(f(4)) - sqr(f(3)) = 16
here we don't have enough 0's left to fill the last group. So, we add the five 0's that were left.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersYou are given a file which contains the following information about users visiting the eBay website:
- tvikranthbabu February 11, 2014 in United States
<user id> <type of page visited> <time stamp>
<user id> is a unique key assigned to every user
<type of page> is one of these "home", "search results", "check out", "payment".
The file contains this information sorted according to the time stamp.
A sequence is defined as a continuous set of three types of pages visited by a user.
Example: if a user visits the following pages. "home" -> "search" -> "search" -> "check out"
{home, search, search} is one sequence for the user, {search, search, checkout} is another sequence for the user.
Design and code to determine which sequence occurs the maximum number of times (for all users).| Report Duplicate | Flag | PURGE
Ebay SDE1 Algorithm - -1of 1 vote
AnswersHow to find the smallest number with just 0 and 7 which is divided by a given number?
- sunny.010203045 February 10, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersGiven a string, write code to find all the rotations of the string. e.g.
- Jeanclaude February 10, 2014 in United States
if TOP is original string, then its rotations are: OPT, PTO & TOP itself.
Follow up question: Given two input strings, for e.g. Str1="TOP", Str2="OPT", write a code to find if one is the rotation of the other. If it is a rotation, return true, else return false.
Condition: Do not use hash tables.| Report Duplicate | Flag | PURGE
Lab126 SDE1 - 1of 1 vote
Answerdef inc:
- sunshihaosd February 09, 2014 in United States
while True:
v = v + 1 //---A
set(s) // ---B
def disp:
while True:
wait(s) //---C
print v //----D
print all possible value, which is shared value. At the begin , v = 0
s is binary semophore. initial value is 0| Report Duplicate | Flag | PURGE
Google SDE1 Algorithm