SDE-2 Interview Questions
- 0of 0 votes
AnswerDesign bus booking system:- Each row has x seat. If customer wants K seats if you have K consecutive seats available, reserve them. Otherwise give seats from any row.
- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersThere is a bridge and N no. people takes (a1,a2,—an) time to cross it and there are K torch and at any time x no of people can pass the bridge and it takes maximum of x people time to cross it. Minimum time required for N persons to cross the bridge.
- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswerThere is a graph where each node represents a city and it contains specific no. of people. A tournament is going on and each match is playing in one city. All city’s people gather to watch match. Traffic department wants to manage how many people travel through city x if match is playing in city y for each x. City x and y can be any city.
- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven an Infinite stream of strings as AAAAABBBCCDDDEEE… How will you arrange characters so that string become unique without duplicates .
- neer.1304 August 30, 2017 in United States
Return true if it is possible to arrange else return -1.
Ex . AAABBCCDEF – O/p ABABCDCEF : Possible . AAAAAAAAAAAAAAAAAAAAAAB : Not possible| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersGiven an array of integers, replace every number with the next higher number to its right. If a number can’t be replaced, we leave it as-it is.
- neer.1304 August 30, 2017 in United States
For example, the list: 5, 2, 1, 4, 6, 7 needs to be changed to 6, 4, 4, 6, 7, 7.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersGiven two unsorted arrays A, B. They can contain duplicates. For each element in A count elements less than or equal to it in array B
- neer.1304 August 30, 2017 in United States
Examples:
Input : A = [1, 2, 3, 4, 7, 9]
B = [0, 1, 2, 1, 1, 4]
Output : [4, 5, 5, 6, 6, 6]| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - -1of 1 vote
AnswerHow do I design a Payment Gateway system? What are the things to consider in this design ?
- koustav.adorable August 28, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook SDE-2 System Design - 1of 1 vote
AnswersWAP to Convert Hex String to Equivalent decimal Integer.
- hprem991 August 23, 2017 in United States| Report Duplicate | Flag | PURGE
SDE-2 - -1of 1 vote
AnswersGiven a matrix. Convert it into a linked list matrix such that each node is connected to its next right and down node.
Ex:
1 2 3
4 5 6
7 8 9
Output:
1->2->3->NULL
| | |
v v v
4->5->6->NULL
| | |
v v v
7->8->9->NULL
| | |
v v v
--NULL-
This is my code.class Ideone { public static void main(String args[]) throws Exception { int arr[][] = { { 1, 2, 3 }, { 4, 5, 6 } }; LList op = convert2DArrintoList(arr, 0, 0); System.out.println(op); } public static LList convert2DArrintoList(int arr[][], int col, int row) { if (col >= arr[0].length || row >= arr.length) return null; return new LList(arr[row][col], convert2DArrintoList(arr, col, row + 1), convert2DArrintoList(arr, col + 1, row)); } static class LList { LList(int data) { this.data = data; } LList(int data, LList down, LList next) { this.data = data; this.down = down; this.next = next; } LList() { this.data = Integer.MAX_VALUE; } @Override public String toString() { return " " + this.data + " "; } int data; LList next; LList prev; LList rand; LList down; } }
Are there better ways of doing it?
- koustav.adorable August 16, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - -1of 1 vote
AnswersGiven a fully connected graph with n nodes and corresponding values. One node can interact with other node at a time, to replace/ignore/add its value to other node’s value. Assuming this operation takes 1 unit of time, how much time would it take for all the nodes to have value equal to sum of all the nodes.
- koustav.adorable August 14, 2017 in United States
Examples : Given a graph with values {1,2,3,4}, find total time it takes, such that all nodes have value as 10.
I am assuming it can be done in O(N).It will take basically two traversals, one for calculating the sum of values of nodes(first traversal), other for replacing the value of the nodes(second traversal).
It will take 2*(no of nodes) time.
Are there any better ways possible ?| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 0of 0 votes
AnswersDesign amazon's frequently viewed product page.
- Nascent August 11, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersDesign a ESPN like system. Ensure scaling and availability. Also one should get all details like score of a player, no. of mtches etc.
- Nascent August 11, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 2 votes
Answerscount number of combinations which are not possible.
- bit32413 August 05, 2017 in United States
There are 'n' empty slots.
A slot can be filled with 'O', 'E', or 'X'
A combination is possible if
1. 'O' s are placed in odd slot , 'E' a are placed in even slots.
2. 'O' and 'E' alternate among them,
i.e (OXOE) not allowed because between O s there is no 'E'; but (OEXXO) is allowed.
some allowed combinations
OEXXX, XXOEO, OXXEX
For 3 slots, not allowed combinations are
OXX
XXO
XEX
XXX
OXO
Only those combinations are considered in which O s and E s are in their respective odd and even slots.
i.e EEXXX will never be considered because a 'E' is in odd slot
A combination isn't allowed if 'O' is not followed by 'E' or vice versa| Report Duplicate | Flag | PURGE
Google SDE-2 Algorithm - 2of 2 votes
AnswersDesign a FIDS(Flight Information Display System)
- AD August 04, 2017 in India
1. Consider most important classes & ignore Interfaces as of now
2. FIDS is not about reservation system but the dasboard to display
3. the information will look like:
DEPARTURES
----------------------
Attributes:
STD Airline Flight Destination/Via CheckInCounter# Gate Status ETD
Values :
12:50 KingFisher 6E352 Hyderabad A-B 23 Check-In Open 13:15
ARRIVALS
-----------------------
Attributes:
STA Airline Flight# Destination/Via Gate Status ETA
Values :
12:50 KingFisher 6E352 UK/Mumbai Terminal2 Landed 13:15| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 0of 0 votes
AnswersWrite a C code matrix multiplication in such a way that the matrix can be read in row major form only
- anaghakr89 July 31, 2017 in United States for Touch system software| Report Duplicate | Flag | PURGE
Qualcomm SDE-2 - 2of 2 votes
AnswersDesign a mall where there are 'm' entry gates and 'n' exit gates. There can be only 'x' number of people inside it. No more then 'x' people can be inside mall at any time.
- neer.1304 July 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Software Design - 0of 0 votes
AnswersHow will you design a true collar?
- Nascent July 27, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 0of 0 votes
AnswersGiven an array of co ordinates (x,y). WAP to figure out if a square can be formed from any four points.
- Nascent July 27, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 0of 0 votes
AnswersGiven a 2d matrix and 4 points. WAP to figure out if they are row wise, column wise of diagonally wise consecutive.
- Nascent July 27, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 0of 0 votes
AnswersThe memmove() function copies n bytes from memory area src to memory area dest. The memory areas may overlap: copying takes place as though the bytes in src are first copied into a temporary array that does not overlap src or dest, and the bytes are then copied from the temporary array to dest.
- jaya.ppatil July 21, 2017 in United States for AWS| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 4of 4 votes
AnswersFind distance between any two nodes of binary tree and binary search tree.
- Raje July 19, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Trees and Graphs - 1of 1 vote
AnswersIdentifying if all the elements of a set (in enterity) is present in a list of sets.
- hulk July 11, 2017 in India
For example checking for set1 = {1,2} in {1,2,3}, {5,6} should return true as {1,2} is present in {1,2,3}. Similiary it will be true for {1,2,8,9}, {1,2,4}
But checking for {1,2} in {1,5,6}, {2,3,1} should return false as {1,5,6} does not contain all elements of {1,2} 2 is missing| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
Answers
- Aalekh Neema July 02, 2017 in IndiaLazy Bartender : There are N number of possible drinks.(n1,n2..) Has C number of fixed customers. Every customer has fixed favourite set of drinks. Bartender has to create least possible number of drinks to suffice need of all the customers Example: Cust1: n3,n7,n5,n2,n9 Cust2: n5 Cust3: n2,n3 Cust4: n4 Cust5: n3,n4,n3,n5,n7,n4 Output: 3(n3,n4,n5)
| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
Answersdesign an employee swap in swap out system.
- ashishsaraswat.iips June 26, 2017 in India
The system will have a machine which records the swap in and swap out.
The user can also login in a portal where he can check his swap in /swap out time. He can correct his time also.
There will be managers for employee who can check the entry for all the employees which are under them and correct their subordinates timings also
There will be HR who can only view the entries for all the employees.
We have to come up with the HLD and LLD for the system| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 0of 0 votes
AnswersGiven an array of numbers and n, find n numbers with most occurrences
- LaterG June 11, 2017 in United States| Report Duplicate | Flag | PURGE
SDE-2 - 1of 1 vote
AnswersFind length of longest palindrome in a string
- LaterG June 11, 2017 in United States| Report Duplicate | Flag | PURGE
SDE-2 - 0of 0 votes
AnswersImplement a cache with timeouts. Keys timeout after a certain expiry time.
- LaterG June 11, 2017 in United States| Report Duplicate | Flag | PURGE
SDE-2 - 0of 0 votes
AnswersConvert number to text. ex. 101 One hundred and one
- LaterG June 11, 2017 in United States| Report Duplicate | Flag | PURGE
SDE-2 - 0of 0 votes
AnswerWAP which accepts a number and keeps track of the median of all the numbers seen till now. You do not have memory to store the entire stream of received numbers.
- LaterG June 11, 2017 in United States| Report Duplicate | Flag | PURGE
SDE-2