SDE1 Interview Questions
- 0of 0 votes
AnswersImplement Stack operations using two queues. I wrote some code, later he asked, how many elements could be added to this queue. (My code was like this Queue<Integer> q1 = new Queue<Integer>(); ) What would be the maximum number of elements that this queue would accomodate? My code was in java.
- Madan January 16, 2014 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - 0of 0 votes
AnswersHow to sort 2 queues without additional containers?
- Gaile January 15, 2014 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 - 0of 0 votes
AnswersProgram an iterator for a Linked List which may include nodes which are nested within other nodes. i.e. (1)->(2)->(3(4))->((5)(6). Iterator returns 1->2->3->4->5->6
- Madan January 13, 2014 in United States| Report Duplicate | Flag | PURGE
Google SDE1 - 1of 1 vote
AnswersOnline assessment:
- 2013renting2013 January 12, 2014 in United States
There are N points on a 2D plane, find the k closest points.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersYou are given an array of integers, sorted, but rotated. Find an better than O(n) algorithm to find an element in an array. Write code for this.
- GSheld January 11, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersYou are given a long list of integers, so long that you can not fit the entire list into memory, implement an algorithm to get the max 100 elements in the list.
- GSheld January 11, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersSecond question is Implement a boolean method for returning whether an appointment with a doctor is possible or not. Given that we have a set of start and end time frames already scheduled with the doctor.
- lks January 10, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersFind the longest common substring between 2 string in O(n) complexity
- lks January 10, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersPrint a 2D array in spiral order.
- GSheld January 10, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersYou are standing at 0 0 and you have to get to i, j. Find the number of ways. Did that with recursion then with DP. Then he extended the question saying some edges are not traversible. Then edges have weights, find min weight path.
- anonymous January 09, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersYou are standing at 0 0 and you have to get to i, j. Find the number of ways.. Then he extended the question saying some edges are not traversible. Then edges have weights, find min weight path.
- anonymous January 09, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersAn array is given representing the colors of n jars, colors have values 0-99. When two jars are mixed the resulting volume is same as volume of one jar. Smoke is color1*color2… and resulting color is (color1+color2)% 100. Keep on mixing colors such that you end up with just one jar with minimum smoke.
- anonymous January 09, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersSecond Question is to Encode a String
- lks January 09, 2014 in United States
aaaabbccdd -> a4b2c2d2
In minimun space and time complexity| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersFirst question is You have two numbers represented by a linked list, where each node contains a single digit. Write a function that adds the two numbers and returns the sum as a linked list
- lks January 09, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersImplement stack with findMiddle and deleteMiddle() in constant time.
- lks January 09, 2014 in United States
Can you please explain and write code for it| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersGiven a binary search tree whose nodes are integers, find the frequency of occurrence of each digit in the tree.tr
- lks January 07, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - 0of 0 votes
AnswersYou have a single string which contains all the positive numbers upto N concatenated together. If you are given an input number then how would you find the index position of the number in the string.
Eg:String str = "12345678910111213141516171819202122232425......upto 10000"; input = 20 should return the index of 20 in the string which is 29
The example string is upto 10000. The actual string can be upto any number N.
- anonymous January 06, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 String Manipulation - 0of 0 votes
AnswersHow would you represent a graph with million nodes ?
- lks January 06, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 1 vote
AnswersThere are two questions that I want to ask.
- lks January 06, 2014 in United States
Q1) divide two numbers without “/”
Q2) judge if there are two numbers in an array add to a given number
For both the questions please consider minimum space and time complexity| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersGiven a collection of 3-set sequences, where a 3-set sequence is defined as a list of 3 different pages (for example: mouse-keyboard-printer is a 3-set sequence, while printer-mouse-keyboard is another) accessed sequentially on amazon.com, find the most common 3-set sequence with minimum space and time complexity
- lks January 06, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 1 vote
AnswersWrite a function to remove all redundant characters in a given string with minimum space and time complexity
- lks January 06, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 2of 2 votes
Answersint sum = 0;
- nirupam.astro January 04, 2014 in India
for (int i = 0; i < m; i++)
for (int j = i + 1; j < n; j++)
for (int k = j + 1; k < l; k++)
sum++;
what will be the value of sum?| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersGiven a linked list of integers, write a function to determine whether the given list has a loop or cycle anywhere in the list. The integer values may not be relied upon to be distinct.
- outside09 December 30, 2013 in United States
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 one of the following skeletons for your solutions.
Java:
public class ListLoopQuestion {
public static class ListNode {
public int value;
public ListNode next;
}
public static boolean hasLoops( ListNode myList ) {
}
}
C++:
struct ListNode {
int value;
ListNode * next;
}
bool hasLoops( ListNode * myList ) {
}| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 2 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.
- outside09 December 30, 2013 in United States
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.
class TestResult{
int studentId;
Date testDate;
int testScore;
}
public Map<Integer, Double> getFinalScores(List<TestResult> resultList){
return null;
}| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 0of 0 votes
AnswersGiven two sorted singly linked lists, implement a function to merge the two lists into a single sorted list and return its head. You may destroy the original lists if you want.
- outside09 December 30, 2013 in United States
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.
Example:
Input:
List 1: 1->2->3->4
List 2: 1->3->5->7
Output:
1->1->2->3->3->4->5->7
Use one of the following skeletons for your solutions.
Java:
public class Node {
public int value;
public Node next;
public Node() {
value = 0;
next = null;
}
public Node(int value, Node next) {
this.value = value;
this.next = next;
}
}
public class MergeListProblem {
public static Node mergeLists(Node head1, Node head2) {
// your code goes here
}
}
C++:
class Node {
public:
int value;
Node* next;
Node() {
value = 0;
next = NULL;
}
Node(int v, Node* n) {
value = v;
next = n;
}
};
Node* mergeLists(Node* head1, Node* head2) {
// your code goes here
}| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersAmazon has many visitors to its site. And it tracks what pages the customers visited, etc and other stuff.
- pulkit.mehra.001 December 26, 2013 in India
Make an efficient data structure for storing 3 days of information of all those customers who have visited site exactly two different days and searched more than 3 unique pages of the site in those 2 days.
So whoever visited site exactly two days out of these three days and visited more then 3 unique pages should be in the contact list.
What's the efficient approach to solve these kinds of problems??| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 1 vote
AnswersImplement data structure for garbage collector in java
- shrey.chaturvedi2525 December 23, 2013 in India| Report Duplicate | Flag | PURGE
Deshaw Inc SDE1 Java - 2of 2 votes
AnswersYou can swap only two consecutive elements. You have to show all steps to convert a string into another string (both strings will be anagrams of each other). E.g. GUM to MUG
- codr December 21, 2013 in United States
GUM
GMU
MGU
MUG| Report Duplicate | Flag | PURGE
Epic Systems SDE1 Algorithm - 0of 0 votes
Answersreverse a single linked link - recursive and iterative. tell the O(n) for each.
- vickykansal December 19, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersQ: Pretend I'm a Dog breeder and you are an SDE. Design a solution for tracking my dog's pedigrees.
- vickykansal December 19, 2013 in United States
Followup - pedigree may also be hybrid. need a data structure which can lookup by pedigree to see if dog exists. also should be able to search by pedigree and some characters of dog.| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures