SDE1 Interview Questions
- 0of 0 votes
AnswersGiven daily stock rates of last year give the average stock rate price for a given day range
- kri1311 May 26, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
AnswersHow would you design Hospital management system ?
- kri1311 May 26, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
AnswerThere are M chocolate packets each packet can have variable number of chocolates in each packet. There are N students (N < M). Distribute chocolate packets to student such that
- kri1311 May 26, 2015 in India
a) each student gets 1 packet
b) suppose m1,m2,…mn are the packets which are chosen to be distributed in sorted order of number of chocolates in them (nm-n1 must be minimum)
M = 1, 3, 4, 6 (4 packets with specified number of chocolates in them)
N = 2
Ans = 3,4| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
AnswersAssume you have a starting 4 digit number, say 1234 and and ending 4 digit number 4567. For changing a bit of a number from 1 to 3 (for example), it will take 2 steps (from 1->2 and from 2->3). So to convert 1234 to 4567, you’ll have to change each and every bit individually in some number of steps. (Change 1->4 in 3 steps, 2->5 in 3 steps and so on). Now there is a list of blacklisted numbers. So while transforming start to end, if you reach a blacklisted number, then you cannot change that particular bit, you’ll have to move to another bit. E.g. Assume 1434 is a blacklisted number, and while transforming you reach it, then you have to change either 1, or 3 or the last 4. So you have to find the least number of steps in which start number can be transformed to end number.
- kri1311 May 26, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
AnswersI was asked to design a snake and ladder game. The game can have more obstacles than just snake and ladders.
- kri1311 May 26, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 - 0of 0 votes
AnswersThere is a n player game of cards. The deck of card is not fair, i.e. any card can be there any number of times. A card has a number and a color. Each player gets k card each (n and k can be harcoded in the solution). The computer starts the game by throwing a card from the deck of cards. Assume the card is 4 of Green. Then the other player has to throw either a 4 of any color or Green of any number. If the player does not have any such card, then it can say pass. The player who finishes all his card wins. The logic of selecting the card by the user can be hardcoded (Eg, If you use a list data structure for storing the cards for a player, then you can say that the player always throws the first card from the list). The logic was required only to start and conclude the game.
- kri1311 May 26, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
AnswersTwo players, two field; and have multiple ships located in their fields. They are guessing each others ship position and hitting. Tell who wins first. Design maintainable code which can incorporate future change.
- kri1311 May 26, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
AnswersDesign a cricket series. Extend it to olympics.
- kri1311 May 26, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
AnswersDesign and build tic tac toe game. The code should be up and running. It should be scalable to multi-users and nXn grid.
- kri1311 May 26, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
Answersadvantages and disadvantages of Circular queue according to its implementation in array and linkedlist ??
- rahulkumar5july May 26, 2015 in India| Report Duplicate | Flag | PURGE
TATA Consultancy Services SDE1 Data Structures - 0of 0 votes
AnswersTwo players, two field; and have multiple ships located in their fields. They are guessing each others ship position and hitting. Tell who wins first. Design maintainable code which can incorporate future change.
- tarunjain07 May 21, 2015 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Object Oriented Design - 0of 0 votes
AnswersPrint the bottom view of the binary tree.
- kri1311 May 19, 2015 in India
Example :
1
/ \
/ \
2 3
/ \ / \
4 5 6 7
/ \ / \
8 9 10 11
/
12
Output should be :
8 12 9 10 5 6 11 7
Solution is different from http://www.geeksforgeeks.org/bottom-view-binary-tree/| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 0of 0 votes
AnswersGiven an array and a target number. you have to print all sequences that generates the target number.
- kri1311 May 18, 2015 in India
you can use two arithmetic operators '+' and '-' to perform operations among array elements.
Note: you can't modify the array and you have to use all the elments of the array. and the order would be same as given in the array.
Example : 1 9 1 2 , Target Number = 9
1 + 9 +1 -2 =9
output should be "1 + 9 +1 -2 "| Report Duplicate | Flag | PURGE
Flipkart SDE1 - 7of 7 votes
AnswersYou are given a list of word. Find if two words can be joined to-gather to form a palindrome. eg Consider a list {bat, tab, cat} Then bat and tab can be joined to gather to form a palindrome.
- um01 May 14, 2015 in United States
Expecting a O(nk) solution where n = number of works and k is length
There can be multiple pairs| Report Duplicate | Flag | PURGE
Google SDE1 Algorithm - 0of 0 votes
AnswersGiven set of job schedules with start and end time, write a function that returns indexes of overlapping sets.
- Tom Walker May 13, 2015 in United States
for ex :-
input -> [1,2][5,6][1,5][7,8][1,6]
return -> [0,1,2,4]| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersWrite a function that accepts root of a binary tree and print zigzag level order traversal, each level print in new line.
- jaip42 May 10, 2015 in India for Kindle
For example,
Given tree:
1
2 3
4 5 6 7
8 9
output:
1
2 3
7 6 5 4
8 9| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersWrite a function that accepts root of a binary tree and return true if it is foldable otherwise return false. A binary tree is foldable if left subtree of root is mirror image if right subtree.
- jaip42 May 10, 2015 in India for Kindle
For example:
Given tree,
1
2 3
4 5 5 4
6 6
output: true| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersWrite a function that accepts root of a binary tree and return true if it is foldable otherwise return false. A binary tree is foldable if left subtree of root is mirror image if right subtree.
- jaip42 May 10, 2015 in India for Kindle
For example:
Given tree,
1
2 3
4 5 5 4
6 6
output: trus| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 1 vote
AnswersWrite a function that accepts root of a binary tree and print zigzag level order traversal, each level print in new line.
- jaip42 May 10, 2015 in India for Kindle
For example,
Given tree:
1
2 3
4 5 6 7
8 9
output:
1
2 3
7 6 5 4
8 9| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 2of 2 votes
AnswersWrite a function that accepts two character arrays each represents a floating point number and return their sum in character array.
- jaip42 May 10, 2015 in India for Kindle
For example function accepts "23.45" and "2.5" and return their sum "25.95".
Restriction: We cannot use predefined functions / methods or parsing. We have to go with basic operations.| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersIn a Formula-1 challenge, there are n teams numbered 1 to n. Each team has a car and a driver. Car’s specification are as follows:
- Nitin Gupta May 06, 2015 in India
– Top speed: (150 + 10 * i) km per hour
– Acceleration: (2 * i) meter per second square.
– Handling factor (hf) = 0.8
– Nitro : Increases the speed to double or top speed, whichever is less. Can be used only once.
Here i is the team number.
The cars line up for the race. The start line for (i + 1)th car is 200 * i meters behind the ith car.
All of them start at the same time and try to attain their top speed. A re-assessment of the positions is done every 2 seconds(So even if the car has crossed the finish line in between, you’ll get to know after 2 seconds). During this assessment, each driver checks if there is any car within 10 meters of his car, his speed reduces to: hf * (speed at that moment). Also, if the driver notices that he is the last one on the race, he uses ‘nitro’.
Taking the number of teams and length of track as the input, Calculate the final speeds and the corresponding completion times.| Report Duplicate | Flag | PURGE
Google SDE1 Algorithm Arrays Data Structures Java Object Oriented Design - 0of 2 votes
AnswersWrite code to rotate a square matrix:
- doomguy May 04, 2015 in United States
Input:
1 2 3
4 5 6
7 8 9
Output:
4 1 2
7 5 3
8 9 6| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersGiven a stairs of very large size. You are standing at the 0th step. You have to perform n actions. 1st action means you can move forward to 1 step or not. 2nd action is you can move 2steps or keep standing. 3rd action is you can move 3 steps or not and so on. Given is a step no. k which is broken. You can't stand on this step. Find out after performing n actions what can be the maximum no. of steps you can go.
- st2581ag10 April 27, 2015 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Puzzle - 0of 0 votes
AnswersGiven a binary tree populate the inorder successor of each node. Do it iteratively.
- firefox April 23, 2015 in India for Kindle| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
Answers{1, 1, 0, 0, 0},
- sunnyg522 April 22, 2015 in United States
{1, 1, 0, 0, 0},
{1, 0, 0, 1, 1},
{0, 0, 0, 0, 0},
{1, 0, 1, 0, 1}
write a function to return the size of max cluster and coordinate of it, max cluster size to the above example is 5.| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 1of 1 vote
AnswersDesign a data structure to keep track of top k elements out of 2 billion records.
- panda April 22, 2015 in India
Each record is numberd with a key which is 30 bit and a number which is count of how many times the customer has visited us.
Come up with an data structure so that the updation of element in 2 billion records will be faster.
Getting top k element will be faster| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 2 votes
AnswersYou are given large number of files each approx: 10MB.
- um01 April 21, 2015 in United States
Assume a million such files.
You are required to find the most frequent word or top 5 most frequent word.
How would you design the solution| Report Duplicate | Flag | PURGE
SDE1 System Design - 0of 0 votes
AnswersFind whether a number (which is less than 10000) is a perfect square or not. If it is perfect square, calculate square root in O(1) without using sqrt function.
- alanturing06022014 April 18, 2015 in United States
Example : 1024 => 32
1025=> not perfect square.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - 3of 3 votes
AnswersGiven a String find the first non repeating char in a single pass of the string.
- um01 April 18, 2015 in United States
Assume a big character set like utf-8 (eleminate use of char[256])
Avoid any subloop to have a very optimal solution| Report Duplicate | Flag | PURGE
Yahoo SDE1 Algorithm