## SDE-2 Interview Questions

- 0of 0 votes
Round 3

Question 1, you are given a puzzle, You can check the image here`https://drive.google.com/file/d/0B6-TjTC-KfTqQThBamxPa0NwNGM/view?usp=sharing`

You have to write a program to provide a solution for this.

- 0of 0 votes
Round 2

Question 1: Design a traffic signalling system for a city.

1.a : think as you were asked this question in a high level meeting with leadership teams, what would you do at that time ?

1.b : what are the check-list/to-do you will do before start of your project.

1.c : how will you go over each and every check-list/to-do

1.d : Once you have done all this, what are the design principle you will follow.

1.e : what kind of system you would choose(I gave distributed/centralized)

1.f : Tell me the pros and cons of these type which you have listed

1.g : how do you go over your goal.

1.h : how will you make the cons go away from one system which out changing it to another type(like possible modification).

1.i : How will to achieve your goal which was given to you by LT team.

1.f : Now lets write the code for a road intersection, make it generic enough both in terms of colors, and ordering, so what it can be used anywhere.

Note that : a road intersection may have many traffic lights one for each side of the roads

- 0of 0 votes
Round 1

Question 1.a

You are given a stock market feed of a single stock.

It contains the change over the previous value. you have to find out the max gain one can get out of it.

Example : -1, 2, 6, -5, -3 7, -3

Days 0 1 2 3 4 5 6

Answer is buy before day 1 and sell it after day two.

WAP for this.

Question 1.b : How do you make the changes in previous code to return the maximum loss. Please note that the changes should be minimum only.

Question 1.c: Lets undo the Question 1.b's additional changes, and now lets you are given a limit on how many days one can hold the money, lets say "k", which means, the investor will give you the money for k days only. you have to again make the additional change to figure out the optimal start date and end date.

Few Example

input : -1 -6 10 2 -5 20 5 -10 6

days 0 1 2 3 4 5 6 7 8

Max Gain : End of first day to end of 6th day, amount is 32.

Max Loss : End of 6th day to end of 7th day, amount is -10.

if K is 3 then the max gain is 25, which is end of 4th day to end of 6th day.

Edits : Interviewer was expecting O(N) solution here.

- 0of 0 votes
Given a pond where all the stones are lined at a distance of one unit (C in each row and there are R such rows).

Each stone has a special value which denotes the length of the jump the frog can make i.e if frog is on stone (x,y) and value is k then frog can jump to (x+dx,y+dy) where dx+dy=k and frog doesn’t leave the bounds.

Find the min number of jumps to reach the stone at (R,C). Also print the path taken by frog to reach the stone.

- 0of 0 votes
Given 1000 elephant ,none of whom exact heights are known, there are statements given which will be of two forms

i- E_i is taller than E_j

OR

ii- E_i is smaller than E_j

Calculate the ascending order of the elephants(in terms of height).

For ex-

1) E1 is taller than E3

2) E3 is smaller than E2

3) E2 is taller than E1

Then order would be E3, E1, E2

- 0of 0 votes
Tech Screening round

Q.1 : a non decreasing sorted array is rotated by some random amount, write a routine to figure out this random amount.you can consider the clockwise rotation.

Write the test cases for it.

Interviewer wanted to see prod ready code.

- 2of 2 votes
Asked like 8 different behavioral questions that were supposed to exemplify Amazon values. I was unprepared for this, as many people say Amazon doesn't do this.

For example, I was asked "Tell me about a time when you solved a complex problem with a simple solution", "Tell me about a time when you increased efficiency", "Tell me about a time when you made a judgement call to take an unknown risk", "Tell me about a time when you disagreed with your team about something and how you reconciled it"

- 0of 0 votes
Find all paths in binary tree that add up to a given sum.

Given a tree like this:`2 3 5 4 8 6 -2 2`

return {3,4}, {2,5}, {2, 5, -2, 2}

- 0of 0 votes
Design the "what other people bought feature." This was focused on database design/creating an api to lie on top of it, and he asked questions to see if I understood how dbs actually work(like what does group by do). I was given an example table with the schema of like

itemID, purchaseDate, customerID

He asked big O complexity of sql query as well.

- 0of 0 votes
Design Amazon Questions and Answers. This question was to see how I code, and how I would modularize things. He wanted me to code every single thing as realistically as possible on a whiteboard.

- 0of 0 votes
Design a push notification system for android. Assume that we have 1 million users this year, but next year we will have 15 million. Assume that Google can handle infinite notifications per second.

I would love to see this answered, as I did not answer it well.

- 0of 0 votes
You are given a String S that consists of characters '0' and '1' only.Return the smallest positive integer K such that it is possible to cut S into K pieces, each of them being a power of 5. If there is no such K, return -1 instead.

Examples

0)

"101101101"

Returns: 3

We can split the given string into three "101"s.

Note that "101" is 5 in binary.

1)

"1111101"

Returns: 1

"1111101" is 5^3.

2)

"110011011"

Returns: 3

Split it into "11001", "101" and "1".

3)

"1000101011"

Returns: -1

4)

"111011100110101100101110111"

Returns: 5

- 0of 0 votes
Design an Email sender, need to send 100,000000 emails and you have 5 machines how could you do it efficiently.

- 0of 0 votes
Given an URL you need to analyze all the images( they may be in 1000’s of number) and return the cumulative quality of images present in that url.

lets say: you can configure image quality as very good, good, average, poor..etc, so you have to return one value among them.The given URL may contain several other URLs and they also contain lot of images . you need to consider all of them. lot of questions like how to avoid visiting same url again,

how would you determine the quality of an image if you encounter an url that contains only an image..etc.

- 0of 0 votes
Design 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.

- 0of 0 votes
In an online teaching system, there are n number of teachers and each one teaches only one subject to any number of students.

And a student can join to any number of teachers to learn those subjects.

And each student can give one preference through which he can get updates about the subject or class timings etc.

Those preferences can be through SMS or twitter/facebook or email..etc.

Design above system and draw the diagram for above.

- 0of 0 votes
How to debug deadlock or heap corruption from DUMP using WinDbg tool?

- 0of 0 votes
Design classes and interface for BookShelf

- 1of 1 vote
Given a file, read last n lines from the file

string ReadNLines(sttring fileName, int n);

- 0of 0 votes
Identify the output

`Class A { } Class B { } B b = new B(); A a = (A) b; sysout(b.getClass()); sysout(a.getClass());`

- 0of 0 votes
Given Two classes A & B. How will B know if an instance of A is already created?

- 0of 0 votes
Log file contains UserId.Every day has new log file.Given range of n days find top 10 users?

- 0of 0 votes
Given an int[] multiply all numbers except index I/p {1,2,3,4} O/P {24,12,8,6} How can you minimize multiplication

- 0of 0 votes
Move all zeros to beginning input {1,2,3,0,0,0,4,5} output {0,0,0,1,2,3,4,5}

- 0of 0 votes
class Node{ int nodeId,int nodeParentId} is given.

Input : List<Node>

Output:Tree

- 0of 0 votes
Design TIC TAC TOE problem

- 4of 4 votes
Given a big rectangular plot of land that has rectangular or square sized buildings (all sides of every building are parallel to the big rectangular plot)... find the location and dimensions of the largest square that can be built in this rectangular plot

- 2of 2 votes
Find the number of bits set in a given character array.

After giving him a bit wise operation that was O(n) where n is the number of bits set, he wanted a more optimum solution

- 1of 1 vote
Given an array of integers and a number. WAP to find the pairs which sum of upto given number.

I solved it. Then he asked about writing test cases for this function.

I wrote below test cases

1.) All the elements should be number.

2.) Length of array should not be 0.

3.) Array itself should not be null.

4.) Given number, arrayLength can be represented by 32bits or 64 bits.

5.) number should not be negative.

6.) Input does not has pair, It should return false

7.) Input has pair, It should return true

8.) Input has all negative values and pair exists, then function should return true

9.) Input has all negative values and pair does not exists, function should return false

He told that he is looking for more test cases. Can you guys think of some more complex test cases.

- 1of 1 vote
You are given a catalog of books, which have following attributes :-

Name, Author, Publisher, Publish year, Category, Price, Count (sold)

Implement following APIs on top of this catalog -

1) addBookToCatalog(Book)

2) searchBook(by partial book name/author)

3) getMostSoldBooks(by author name/category, limit)

Expectations:

Maintain DB on memory

Code should be readable. Design, handle naming convention,handle exceptions & should be running