SDE-2 Interview Questions
- 0of 0 votes
AnswersGiven login/logout time of all users for a particular website in below form.
- dggn February 26, 2016 in India
userId, login time, logout time.
Now store this data in some data structure, so that we can efficiently query total number of users who logedin and logedout in given time range.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Data Structures - 1of 1 vote
AnswersGiven an array of 0s and 1s, and k, Find the longest continuous streak of 1s after flipping k 0s to 1s.
- neer.1304 February 14, 2016 in United States
E.x array is {1,1,0,0,1,1,1,0,1,1}
k = 1 (which means we can flip ‘k’ one 0 to 1)
Answer: 6 (if we flip 0 at index 7, we get the longest continuous streak of 1s having length 6)| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersDesign a chat application. How will u handle huge data?
- Nascent February 07, 2016 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersDesign an online pizza delivery system. Complete OO Design needed.
- Nascent February 07, 2016 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersOrganization has online services running across world. To use online services, User create account by entering personal details like - First Name, Last Name, Phone number, Address and etc...
- Raj January 23, 2016 in United States for IT
Russia has passed new law that any Russian citizen who is creating account to use online services, his account information needs to store in Russia first and then read-only copies allowed to replicate across the world.
Please suggest cost effective solution/design for this scenario otherwise online services will be blocked to use in Russia. How do we handle if any other country Germany is also come up with this law?
Issues:
1. Do not have mechanism to identify citizenship of user.
2. If Russia user creates an account, he/she should not wait to use online services.
What is cost effective solution?| Report Duplicate | Flag | PURGE
SDE-2 Brain Teasers - 0of 0 votes
AnswersImplement a finite state machine.
- neer.1304 January 18, 2016 in United States
– The machine should have one start state and can have multiple end states
– It should be extensible (I should be able to add any number of states or transitions at any time)
– I should be able to set notifications on or off for any state or for the whole state machine| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersYou are given some equations which may contain > or = on different-different operand. For example there are valid input and invalid (a=5, b<a=50)
- neer.1304 January 18, 2016 in United States
String e1 = "a>b=1";
String e2 = "a>b=2";
String e3 = "a>c>e=3";
String e4 = "a>c>f=4";
String e5 = "b>a=5";
String e6 = "a>b>c=5";
String e7 = "b=7";
String e8 = "a>b>c>d=99";
String e9 = "a>b=99";
You need to create JSON string from it.
{
‘a’: {
‘b’: [1,2,99],
‘c’: {
‘e’:3,
‘f’:4
}
},
‘b’: {
‘a’ : 5
}
}
Input: You are given those string in string array
Output:
Construct JSON
Print it| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersThere is down-turn in the ship-building industry. Ace Shipping Corp (ASC) wants to be prepared by having a system that will help evaluate the total cost saving they will achieve if they were to ‘let go’ some employees.
- neer.1304 January 18, 2016 in United States
Following are the rules for drawing up this Firing List:
Each manager at every level in the organization will have to contribute ‘heads’ from his team to the firing list
The input to the system would be a small integer k (=1,2, etc) which would be the number of employees chosen per manager. The output would be the total cost saved for this k. Different values of k would give an idea of the total cost saving achieved.
The primary selection criteria is Performance Rating. k employees with the minimum rating under a given manager are to be selected.
If two employees have the same rating, the one with the higher salary gets selected (to maximize cost saved)
The activity might be requested for the sub-org under any manager. The default is to consider the entire org.
Although total number of reportees for a manager is usually of the order of 10, it could possibly be a much larger number in some org too. An optimal way of choosing the k reportees would be preferred.
The following information needs to get stored per Employee:
Employee ID (unique)
Name
Performance Rating (1-5, 1 is lowest, 5 is highest)
Salary (Rs)| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersDescription:
- nasbtv January 15, 2016 in India
A company, create classes for each type of employee and calculate working hours and wages/salaries that will be received.
Example General Manager, IT Manager, Accounting, Marketing, Finance, Procurement Managers
Manager and Higher level employees wont have overtime wage. Overtime wage is 1.5 times higher than the usual wage. Working hours are limited as 8 hours. More than this limit will be considered as overtime.
Inputs:
Employee Name, Surname
Title/Role
Salary
Daily Working hour
Outputs:
Date
Employee Name, Surname
Daily Wage.| Report Duplicate | Flag | PURGE
Amazon SDE-2 C++ - 0of 0 votes
AnswersThere is a car company and customers ask the car company for 'n' cars for start - end time intervals.
- rishab99999 January 13, 2016 in India
A company can get multiples request for the cars, find the minimum numbers of cars that the car company should have, to satisfy all the requirement for the given list of time intervals:
Eg :
for interval 1-3 cars needed are 2
for interval 2 -3 cars needed are 3
for intervals 3-4 cars needed are 4
for intervals 5-6 cars needed are 2
Answer is 5 for above, as we there is overlap between interval 1-3 & 2-3| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersI have a photo storage service. The actual photos are present in some storage and the index of these photos is present at some other place. The index is huge, say trillions of photos. Design the class for index node of each photo (with attributes like name*, date*, size*, accesscontrol, camera details, shot details, etc) such that 1. It is serializable. 2. For faster processing, I am interested in first 3 attributes. When deserializing the bytes of object, parse these 3 attributes i.e. instead of deserializing whole class, deserialize only part of the class (members marked by*), other members of class should be deserialized on demand with another call.
- AnonymousN January 10, 2016 in United States
How will you test the performance of your serialization/ deserialization?| Report Duplicate | Flag | PURGE
Amazon SDE-2 Java - 0of 0 votes
Answersthere is a chess board of dimension n X n. You are given with 2 squares on that board S(x1,y1) ;M(x2,y2). S is a fixed point. M can move diagonally. it can move any number of steps or jumps in 1 move . Find the minimum number of moves M needs to reach S
- mohapatrasandeep60 January 09, 2016 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Coding - 1of 1 vote
Answersthere is a news publishing/subscribing product of Amazon where electronic contents are collected from owners like newspaper, magazines. Customer is using kindle. Design how customer will get the content when his system kindle connects to net. how to send the contents to device?
- mohapatrasandeep60 January 09, 2016 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Software Design - 0of 0 votes
AnswersThis was a design question, discuss data structures/ complexities, etc.
- AnonymousN January 05, 2016 in United States
There is a huge HashMap (Key-Value store). This is present in storage, dont worry about the Storage.
1. Build its index. Distributed system for indexing. Different cases: Key is a String/ Double/ complex structure, etc. How will you replicate this index structure - whole index is replicated/ parts of index are replicated.
2. How will you synchronize access (read/ write) if there are multiple replicas of the index partition. What if the actual Storage partition also has replicas.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Distributed Computing - 0of 0 votes
AnswersYou have a function f1() that generates 0 or 1 with the equal probability. Write a function f200() that generates a number between 1 and 200 with equal probability.
- holdnet January 04, 2016 in United States| Report Duplicate | Flag | PURGE
Big Fish SDE-2 Algorithm - 0of 0 votes
AnswersPlease analyze the two slightly obfuscated Tcl procedures below and document the code as it should be. Please change the symbol names to reasonable descriptive names. In addition, an explanation of why these procedures might or might not be useful or suggestions for improvements would be most welcome. This code comes from the application you would be working on. I replaced the names and removed the comments to make the challenge. Feel free to do research and experimentation, but please do not ask anyone else to solve it for you. proc f1 {a} { set n [llength $a] set p {} for {set i 0} {$i < $n} {incr i} { for {set j [expr {$i + 1}]} {$j < $n} {incr j} { lappend p [list [lindex $a $i] [lindex $a $j]] } } return $p }
- raghu.aok December 16, 2015 in Indiaproc f2 {fn lst {vn {}\}} { set result {} lassign $fn a b n if {$n eq {}} { set n {::} } set cl {} foreach n $vn { upvar 1 $n v set cl "${cl}set $n {$v}\n" } set cfn [list $a "${cl}${b}" $n] foreach item $lst { lappend result [apply $cfn $item] } return $result }
| Report Duplicate | Flag | PURGE
SDE-2 Coding - 0of 0 votes
AnswersGiven a log file:
- AnonymousN December 15, 2015 in United States
some garbage...from:123.54,78.21...more garbage..to:56,82,124.54...more
some more garbage...from:11.54,45.84...garbage..to:115.87,98.65
...
Write a program or shell script to return pairs of (from, to) coordinates.
Assumption: these coordinates will always appear in sequence: from ... to... from ... to...
But these from - to pair may or may not be on same line.| Report Duplicate | Flag | PURGE
Amazon SDE-2 shell scripting - 1of 1 vote
AnswersYou have a BST and you need to assign an appropriate value to neighbor of all nodes (Explained in below example)
Node Structurenode { node leftChild, node rightChild, T data, node neighbor }
A
- avinash.setty December 12, 2015 in United States for Marketplace
/ \
B C
/ \ \
D E F
Based on above tree,
Node: Neighbor
A: NULL
B: C
D: E
E: F| Report Duplicate | Flag | PURGE
Amazon SDE-2 Trees and Graphs - 0of 0 votes
AnswersGiven an array of stock values of a company. Find out the time when a user would have bought the stock and sold the sock. Basically find the maximum positive difference of any two given elements in an array?
- avinash.setty December 12, 2015 in United States for Marketplace| Report Duplicate | Flag | PURGE
Amazon SDE-2 Arrays - 2of 2 votes
AnswersGiven a binary tree print it in inward spiral order i.e first print level 1, then level n, then level 2, then n-1 and so on.
- neer.1304 December 10, 2015 in United States
For Ex -
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
Print- 1 15 14 13 12 11 10 9 8 2 3 7 6 5 4
Follow up question - Extend the algorithm to n-ary tree.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 3of 3 votes
AnswersGiven a singly connected linked list, find the largest palindrome in the list in O(1) space.
- neer.1304 November 29, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 3of 3 votes
AnswersGiven a linked list consisting of String in each Node . Given just a pointer to the head Node find whether the resultant String formed by combining all the Nodes of the linked list is a palindrome or not in O(1) space and O(n) time.
- neer.1304 November 29, 2015 in United States
eg – Consider this linked List structure
“aba” -> “cd” -> “efe” -> “d” -> “caba”
Hence this structure is palindrome .| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersFace to Face
- siva.sai.2020 November 29, 2015 in United States
Q4) two arrays given to you. First array contains number s. Second array contains key values.
We need to find smallest window in first array which covers all second array elements.
e.g:
Input= {6,7,1,3,2,4,5,2,3,1,2,5}
Keys = {2,5,1}
answer: from 9th index to 11th index is the smallest window.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
AnswersFace to face
- siva.sai.2020 November 29, 2015 in India
Q3) stream of numbers coming, get 'n' min elements at any point of time| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersWritten test:
- siva.sai.2020 November 29, 2015 in India
Q2) in single linked list reverse alternative k nodes.
e.g. k=3 , 1->2->3->4->5->6->7->8->9->10
3->2->1->4->5->6->9->8->7->10
void reverseAlternativeKNodes(node *&head, int k);| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersWritten Test question:
- siva.sai.2020 November 29, 2015 in India
Q1) Given binary tree find largestPath size from one leaf to another leaf.
int getLargestPathSize(node *root);| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - -1of 1 vote
AnswerGiven an N-ary tree with thousands of nodes in it. Pair (Join) the Leaf nodes which do NOT SHARE the common path. i.e. Two Leaves can be Paired only if they do NOT have Intersecting path.
- neer.1304 November 28, 2015 in United States
For example,
A
/ | \
B C D
/ / | \
E F G H
Leaf nodes: E, F, G, H & D
Possible Pairs in O/Ps:
a) (E-F), (G-H) or
b) (E-G), (F-H) or
c) (E-H), (F-G) or
d) (E-D), (F-G) or
e) (E-D), (G-H) or
f) (E-D), (F-H) or
g) (D-H), (F-G) or
h) (D-G), (F-H) or
i) (D-F), (G-H)
Note: If we pair(join) say, (E-F) then we can NOT pair any of the (D-G) or (D-H) as they SHARE the COMMON path from A to C.
i.e. E-B-A-C-F —> (E-F) pair
D-A-C-G —> (D-G) pair
D-A-C-H —> (D-H) pair| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven a tree, and a pointer to some node in the tree, print the left most element in the same level as that node
- neer.1304 November 28, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven an input of the calendar objects of 10,000 employees, input is a time interval T and an employee[] array, find the first interval where all the employees in the employee[] array are free for a minimum time interval T (i.e schedule the meeting)
- neer.1304 November 28, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 2 votes
AnswersGiven a binary tree, connect all node in the same level in toggle manner.
- neer.1304 November 27, 2015 in United States
Toggle the linking every K level. For first K level, you should link to next right node. Next K you should link to next left and so on.
Node structure is :
struct node
{
int data;
struct node *left, *right, *next;
};
Each level next should point to the next right or left node in the level. For last node in each level, next should be NULL
For ex - if K=2 then for first 2 level of tree connect next pointer from left to right and for next 2 levels connect next pointer from right to left and so on.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm
Open Chat in New Window