SDE1 Interview Questions
- 0of 0 votes
AnswersDesign an algorithm to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not. also do with o(n2),o(n),o(1) ,write test case and breake the algorithm whatever you write.
- kumar.prince6 April 11, 2013 in India for IDC| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersN boys are sitting in a circle. Each of them have some apples in their hand.
- pavi.8081 April 09, 2013 in United States
You find that the total number of the apples can be divided by N.
So you want to divide the apples equally among all the boys.
But they are so lazy that each one of them only wants to give one apple to one of the neighbors at one step.
Calculate the minimal number of steps to make each boy have the same number of apples.
Input Given:
1. A number N => number of children.
2. Sequence of N numbers, each representing number of apples a child has.
<<P.S.>>
Passing an apple means a child giving away one apple to one of its neighbour.
Even if 2 separate children can pass apples simultaneously or one child can pass 1-1 apple to each of its neighbours then that will still be counted as 2 steps and not 1 step.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersGiven a BST and two values a and b, write a method which returns number of nodes in this tree such that a < node value < b
- kumar.prince6 April 04, 2013 in India| Report Duplicate | Flag | PURGE
Groupon SDE1 Algorithm - 0of 0 votes
AnswersIn a grid, you are given a position, and every location has some value. find the shortest length so that you can touch to any boundary of the grid. I code it then she asked me to optimize it, I did that also.
- kumar.prince6 April 03, 2013 in United States| Report Duplicate | Flag | PURGE
Groupon SDE1 - 0of 0 votes
AnswersYou have a binary tree on client machine, how will u send this info to server and how will you again maintain the tree over the server. I thought few mins, tell him my approach, he was asking for easier way. Then finally I told him my approach. He was satisfied and told me to write the code how and what info will u send and how will u again maintain it on the server, I write both the codes and He was very satisfied with my code.
- kumar.prince6 April 03, 2013 in United States| Report Duplicate | Flag | PURGE
Groupon SDE1 - 0of 0 votes
AnswersYou have a robot in a grid, it can move in forward direction and can change its facing towards north, south, east n west and you are given a command sequence. So what will be the final position of the robot
- kumar.prince6 April 03, 2013 in India
Example
Grid(100*500)
Robot Position – (5,3)
Sequence — {N,S,M,M,E,W,E,S,M,S,M} North, East, West, South, Move forward| Report Duplicate | Flag | PURGE
Groupon SDE1 Algorithm - 2of 2 votes
Answersint board[8][8] each value in the matrix represents a character. 1-9 number represents all whites and 11-19 represents all blacks.
- ANONU March 27, 2013 in United States
Given a pawn at (x,y) print all possible moves. Assume whites are index 0 and blacks are at index 7.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 4 votes
AnswersThe cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days
- ANONU March 27, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 2 votes
AnswersFind top k searched elements from a continuous stream of data.
- firefox March 25, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 5of 5 votes
Answerswaf to rotate array by k unit
- pintuguptajuit(PINTU GUPTA) March 25, 2013 in India
size of array n=6
1 2 3 4 5 6
k=2
output
5 6 1 2 3 4| Report Duplicate | Flag | PURGE
Microsoft SDE1 - 0of 0 votes
AnswersIn an interview I was asked a question on strings. The problem is given a string s1= "ABCDBCCDABCD". and a pattern "BC". we have to replace this pattern with other string ("UVW" or "U"or "uv"). Do this without creating new string.
- yogi.rulzz March 24, 2013 in United States
Take the case to replace "BC" with following
a) "uvw" s1=AUVWDUVWCDAUVWD .
b) "U" s1=AUDUCDAUD .
c) "UV" s1=AUVDUVCDAUVD .
This was my first question and I was stuck on this. :(| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - -2of 2 votes
AnswersGiven 2 arrays with numbers, multiply the numbers with corresponding indexes and return the sum of all the products.
- Nitin Gupta March 20, 2013 in India for WebStore
Twist :- When one array gets consumed then start with its first element again.
A : 1,2,3,4,5
B : 2,1
Output: 24 (1*2 + 2*1 + 3*2 + 4*1 + 5*2)| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - -1of 3 votes
AnswersPrint N numbers of form 2^i.5^j in increasing order for all i >= 0 , j >= 0 ?
- Nitin Gupta March 20, 2013 in India for WebStore
Example : - 1,2,4,5,8,10,16,20.....| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 3 votes
AnswersWrite a program to find the element in an array that is repeated more than half number of times. Return -1 if no such element is found.
- Expressions March 19, 2013 in India| Report Duplicate | Flag | PURGE
Linkedin SDE1 Arrays - 0of 2 votes
AnswersFind kth Largest element in BST
- Razz March 06, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 2 votes
AnswersI have a list of N teams T1, T2, T3 … Tn. Each of these teams has played a match against every other team. I have a function displayResult(Team T1, Team T2), it returns the team which won the match between any two given teams T1 and T2.
- Nitin Gupta October 05, 2012 in India
I have to write the teams in an order such the (n-1)th team (in the order) had lost to the nth team which in turn had lost to (n+1)th team..Write Code| Report Duplicate | Flag | PURGE
Adobe MTS SDE1 Algorithm Data Structures