SDE-2 Interview Questions
- 0of 0 votes
AnswersDevelop a program to demonstrate your implementation of a CSV parsing framework which can be used to generically parse given CSV file into Java beans and prints out information about parsed objects using toString(). The program should follow OOAD open-closed principle to avoid/minimize modification of code when new types are added in future.
- poorna.chandra.akp March 03, 2014 in United States
You should accept input from STDIN and print the output to STDOUT.
Assume following input format and study sample inputs given below:
Data-type
Header-Row
Data-Row-1
Data-Row-2
....
Data-Row-N
The first line indicates the entity type, 2nd line is comma separate list of column names, 3rd line onwards is the comma separated data values.
Test Case 1 Input
Type:Employee
name,age,salary
Ashok,36,20000
Kishor,30,15000
Bharath,25,30000
Expected Output
Name : Ashok;Age : 36
Name : Kishor;Age : 30
Name : Bharath;Age : 25
Test Case 2 Input
Type:Department
code,name
acc,accounts
prl,payroll
Expected Output
Code : acc;Name : accounts
Code : prl;Name : payroll
Your solution should parse the input into Java Beans (POJOs). For example, in test case 1, you will be make use of following Java bean (if you chose Java as programming language, and equivalent if you were using other language).
class Employee {
private String name;
private int age;
private int salary;
public Employee() {
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setAge(int age) {
this.age = age;
}
public int getAge() {
return this.age;
}
public void setSalary(int salary) {
this.salary = salary;
}
public int getSalary() {
return this.salary;
}
public String toString() {
return "Name : " + this.name + ";" + "Age : " + this.age;
}
}
You can create a similar bean for Department as required for test case 2.| Report Duplicate | Flag | PURGE
Epic Systems SDE-2 - 0of 0 votes
AnswersAn array is given like {3,6,10,4,5,7,8}. Pick any two number suppose 10 and then 7, as 10 >7, it's an inversion, now if you choose 3 & 5, 3<5, it's not an inversion.
- Grace March 03, 2014 in India for Kindle
So you have to write a program to calculate total no of such inversion, in a given array. You can use extra space of O(n).| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 2of 4 votes
AnswersGiven an Array, replace each element in the Array with its Next Element(To its RHS) which is Larger than it. If no such element exists, then no need to replace.
- R@M3$H.N March 03, 2014 in United States
Ex:
i/p: {2,12,8,6,5,1,2,10,3,2}
o/p:{12,12,10,10,10,2,10,10,3,2}| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 3 votes
AnswersOne of the questions in one of the interviews -
- pretentious.bastard March 03, 2014 in United States for SQL BI
Given a stack S and another empty stack T and a variable v, write a function that returns S but with its elements reversed.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Stacks - 0of 0 votes
AnswersDesign a download manager. The download manager would be shipped with a browser. Detailed design of components and interaction between them.
- pretentious.bastard February 24, 2014 in United States for Windows Azure Mobile
Follow up question - What features would you add to the download manager so that it is more marketable than others.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Object Oriented Design - 0of 0 votes
AnswersShopkeeper want sells in the packs of 20,9 and 6. Given an n, you need to find whether its possible to buy the items or not.For example n=21, you can buy 2 packs of 6 and one pack of 9(2*6 + 9)
- prince February 17, 2014 in India
Output 1 if possible and 0 if not
Test cases:
1) n=47 ==> possible, output = 1
2) n=7 ===> not possible, output = 0| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 2 votes
AnswersConsider 0 as water and 1 as land. Write code in C to find out whether there is pool in the following matrices.
- bks February 09, 2014 in India
11111
10001
10001
11111
above matrix is pool
11111
11001
11001
10111
11111
above matrix is NOT pool
11111
11001
11001
10001
11111
above matrix is pool
11111
11101
11001
10001
11111
above matrix is pool| Report Duplicate | Flag | PURGE
Amazon SDE-2 C - 1of 3 votes
AnswersThere are N objects kept in a row. The ith object is at position x_i. You want to partition them into K groups. You want to move all objects belonging to the same group to the same position. Objects in two different groups may be placed at the same position. What is the minimum total amount by which you need to move the objects to accomplish this?
- saumya.tyagi6 February 01, 2014 in United States
Input:
The first line contains the number of test cases T. T test cases follow. The first line contains N and K. The next line contains N space seperated integers, denoting the original positions x_i of the objects.
Output:
Output T lines, containing the total minimum amount by which the objects should be moved.
Constraints:
1 <= T <= 1000
1 <= K <= N <= 200
0 <= x_i <= 1000
Sample Input:
3
3 3
1 1 3
3 2
1 2 4
4 2
1 2 5 7
Sample Output:
0
1
3
Explanation:
For the first case, there is no need to move any object.
For the second case, group objects 1 and 2 together by moving the first object to position 2.
For the third case, group objects 1 and 2 together by moving the first object to position 2 and group objects 3 and 4 together by moving object 3 to position 7. Thus the answer is 1 + 2 = 3.| Report Duplicate | Flag | PURGE
Facebook SDE-2 Algorithm - 1of 1 vote
AnswersGiven an input string.
- poorna.chandra.akp January 30, 2014 in India for digital platform
* It has numbers from M to N in increasing order. But no prior information about the values of M and N.
* There is one missing number.
Output the missing number.
Eg.
I/p: 960961962964
O/p: 963
I/p: 12345789
o/p: 6| Report Duplicate | Flag | PURGE
Flipkart SDE-2 - 0of 0 votes
Answersgiven 2 Dimensional array
- xyz January 30, 2014 in United States
I/P -- String[][] input = { { "abc", "def", "gh" },
{ "f", "g" },
{ "qrt","xyz","pqr" } };
Program shd return a 2-D Array with
O/P -- { { "abcfqrt", "abcfxyz", "abcfpqr" ,abcgqrt and so on ..| Report Duplicate | Flag | PURGE
Google SDE-2 Arrays - 1of 1 vote
AnswersGiven 2D matrix of chars, you can find substring by moving in any [of 8]direction inside the range.
- shsf January 28, 2014 in India
Get the list of sorted palindromes without duplicate which are available inside all possible substring in the Matrix.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
AnswersFind the digits count in the number from Range 0-n
- shsf January 28, 2014 in India
For Example: Input range 0-10
count[0]=2
.
.
.
count[9] =1| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 2of 2 votes
AnswersYou are given numbers from 1 through 100 in an array, there is one number missing, find that one
- juny January 26, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersSuppose you are given one number decomposed in binary representation.
- Ruhan January 26, 2014 in India
Input : 101011
Output : 000000
Needs to write algo and tell the approach in how efficiently we can flip the given input numbers to all zero's
Interviewer not mentioned about time complexity but it should be very efficient.| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersDesign a job scheduler.
- shsf January 25, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 0of 0 votes
AnswersDesign news aggregator like google news, without using pull, push or page crawl. Explain how are you going to scale it.
- shsf January 25, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 0of 0 votes
AnswersYou are a cashier, and any item purchased in the store is in the range of 1c to 99c . Customer always pays 100 c i.e 1$. You need to deliver change with 25c, 10c,5c ,1c.
- juny January 22, 2014 in United States for Traffic
1. Code to get the most optimal solution with lease number of coins used
2. Some time in India 1 Rs = 150 ps and following coins were available {50,25,20,10,5,2,1}. Here if the change was 40, you should display 2 20ps and not 25ps,10ps,5ps. . What are the optimizations you will make| Report Duplicate | Flag | PURGE
Ebay SDE-2 - 1of 1 vote
AnswersGiven a 3-D array, if any m[r][c][d] is <=0 mark all the cells in the entire row,col and depth as zero and return the o/p array
- juny January 22, 2014 in United States for Traffic| Report Duplicate | Flag | PURGE
Ebay SDE-2 Arrays - 0of 0 votes
AnswersDesign event system, that is receiving events from various client (iPad,mobile,browser) across the world. It is getting approx 1 billion events /day. At any point of time the PM comes and says , retrieve how many events occurred in last 60s and we should be able to retrieve that
- juny January 22, 2014 in United States for Traffic| Report Duplicate | Flag | PURGE
Ebay SDE-2 System Design - 1of 1 vote
AnswersGiven an integer array find all pythogorean triplets. a^2 + b^2 = c^2 print the a,b,c and their indexes
- avinash January 20, 2014 in India for Global Payment Services| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 2of 4 votes
AnswersGiven a Binary tree and a arbirary node of that tree , find all the nodes at a Distance of K from that Node .Nodes DON’T have parent pointers
- Rahul Sharma January 19, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersYou are responsible for maintaining a web service that sits behind a load balancer. If the web service starts failing, how will you go about fixing it?
- anon123 January 15, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Behavioral - 0of 0 votes
AnswersDesign "YOU TUBE".
- iplayilearnkadugodi January 15, 2014 in India
Like how do you upload/where to do you upload/how do you fetch/ how millions of incoming requests will be addressed.
Also take care of things like how do you provide services.| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 1of 1 vote
Answers
- Srigopal Chitrapu January 15, 2014 in United StatesIn given array find zero and replace the entire row and column with zeros E.g Input: 1 2 3 4 5 6 7 8 9 10 0 11 12 13 14 15 Output: 1 2 0 4 5 6 0 8 0 0 0 0 12 13 0 15
| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Arrays Coding Matrix - 0of 0 votes
AnswersWrite a function which verifies a binary tree where all leaf nodes are at the same level.
- v.vinay.k January 12, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 2 votes
AnswersDesign a Logging mechanism. Should be thread safe.
- R@M3$H.N January 07, 2014 in India
Initially i came up with Command Pattern, and write into a File. Was asked how i will synchronize multiple threads writing into Same File?
Later he gave hint about Aspect-oriented Programming(AOP). And also he gave a hint of Not always writing into the File, can also be a Mail,etc..| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Data Structures Problem Solving System Design Threads Unix - 0of 0 votes
AnswersImplement a circular queue of integers of user-specified size using a simple array. Provide routines to initialize(), enqueue() and dequeue() the queue. Make it thread safe.
- Madan December 18, 2013 in United States| Report Duplicate | Flag | PURGE
Google SDE-2 - 2of 2 votes
AnswersWrite a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function
- Madan December 18, 2013 in United States| Report Duplicate | Flag | PURGE
Google SDE-2 - 0of 0 votes
AnswersIdentifying the number of occurrences of each palindrome in a file
- difuser123 December 15, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 1of 1 vote
AnswersGiven 78 cents (target) you need to tell how many ways it is possible to make the change using 25 cents(quarter), 10 cents(nickel), 5cents(dime), 1cents(penny)
- juny December 12, 2013 in United States for Traffic| Report Duplicate | Flag | PURGE
Ebay SDE-2 Algorithm