Microsoft Interview Questions
- -3of 3 votes
AnswersConvert an unordered tree to a binary tree
- mh4wt@virginia.edu December 18, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java Trees and Graphs - 1of 1 vote
Answersmerge two binary search trees
- mh4wt@virginia.edu December 18, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java Trees and Graphs - 0of 0 votes
AnswersSort a stack using only one other stack and no recursion.
- mh4wt@virginia.edu December 18, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Stacks - 1of 1 vote
AnswersGiven a dictionary and an char array print all the valid words that are possible using char from the array.
- neer.1304 December 02, 2016 in United States
Ex- char[] arr = {'e','o','b', 'a','m','g', 'l'}
Dict - {"go","bat","me","eat","goal", "boy", "run"}
Print - go, me, goal.
We can pre-compute as much we want but the query time must be optimal.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 1of 1 vote
AnswersYou are given a function getNum() that returns a random number in the range 1 to 10 million with repetitions. However, it may also return -1 when it no longer provides numbers. Write a function that calls getNum() continuously until it returns -1 (if a repetition, should not store it); as soon as u see -1, stop calling getnum() and print all the numbers seen so far in a sorted way. Condition: You have got very limited memory to work with.
- Shankar November 20, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Developer Data Structures - 1of 1 vote
AnswersYou have a matrix that is sorted as such: For each value, every index to its right and below it must be larger than the current space's value. Likewise, all entries to its left and above it must be smaller than the current value. How would you go about searching this matrix for a specific number, given its sorted nature?
- oxymoronic2012 November 02, 2016 in United States for Bing| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Intern Matrix - 2of 2 votes
AnswersJust a disclaimer: I doubt you will ever get this interview question. My interviewer even started off by saying, "Hmm, well this isn't really fair, but..." So don't place too much stock in whether or not you can solve this.
- oxymoronic2012 November 02, 2016 in United States for Bing
Question: You have a group of pigs and buckets of food for said pigs. There are 1,000 buckets of food, and exactly 1 of them is poisoned. Your goal is to determine, by the end of 1 hour, which bucket is poisoned.
The poison takes 30 minutes to kill a pig, and you'd like to kill as few pigs as possible. The number of pigs you can test is limitless, and you can assign a number to each bucket and each pig so that you know exactly which pig ate from which bucket(s). You determine which buckets to feed to which pigs, but you have no timer and no way to guesstimate the time. What is the minimum number of pigs you need to use to solve the problem?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Intern Brain Teasers - 0of 0 votes
AnswersYou are given an array of positive and negative integers. If a number n at an index is positive, then move forward n steps. Conversely, if it's negative, move backward n steps. Determine if there is a loop in this array.
- shreydesai@utexas.edu October 29, 2016 in United States
For example, given the array [2, -1, 1, 2, 2], index 0 maps to index 2, 1 maps to 0, 2 maps to 3, and so on. There is a loop in this array because 0 maps to 2, 2 maps to 3, and 3 maps to 0 (use the modulo operator).| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Intern Arrays - 0of 0 votes
Answer1. If I say quick sort takes O(e^n ) on the average, would I be wrong?
- NoOne October 21, 2016 in India
2. Do you think O( f ) is a good idea for real engineering?
3.Given a choice, what other 'order of' measure would you propose to use ?
4. Do you see a real problem with the modified *order of* ?
5. If you were to sort 10 elements, what sorting method would you have used?
6. If you were to sort 1 trillion unicode characters, what sorting method you would have used?| Report Duplicate | Flag | PURGE
Microsoft SDET Algorithm Math & Computation - 0of 0 votes
AnswersThe actual problem from question?id=6289136497459200
Implement pow, with :// Assume C/C++, as of now double pow ( double x, double power )
No library functions allowed.
Should return : x^power
=== Edit ===
People took it a bit trivially, thus examples should help :
- NoOne October 20, 2016 in United Statesx = pow ( 4, 0.5 ) // x = 2.0 x = pow ( 8, 0.333333333 ) // 1.99999999986137069 x = pow ( 10.1 , 2.13 ) // 137.78582031242644
| Report Duplicate | Flag | PURGE
Microsoft SDET Algorithm - 1of 1 vote
Answersdetermine whether a word is in a stored list;
- kanukadze October 18, 2016 in United States
the list doesn't fit into memory;
no disk access allowed, for lookups, memory access only;
no false positives allowed, false negatives ok| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Algorithm - 1of 1 vote
AnswersA list of words is given and a bigger string given how can we find whether the string is a permutation of the smaller strings.
- novicedhunnu September 15, 2016 in India
eg- s= badactorgoodacting dict[]={'actor','bad','act','good'] FALSE
eg- s= badactorgoodacting dict[]={'actor','bad','acting','good'] TRUE
The smaller words themselves don't need to be permuted. The question is whether we can find a ordering of the smaller strings such that if concatenated in that order it gives the larger string
One more constraint - some words from dict[] may also be left over unused| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - 0of 0 votes
AnswersSuggest a data structure and implement efficient phrase search along with word search in a huge chunk of text.
- novicedhunnu August 14, 2016 in India for N/A| Report Duplicate | Flag | PURGE
Microsoft Software Developer Trees and Graphs - 0of 0 votes
AnswersDesign a system for searching strings in files present on a fileserver under a directory. there won't be any sub-directories. There could be more than thousand/lakhs files. And the file size could be in GBs. The matching line should be written to a single file. user will execute grep "string"
- maske.s August 10, 2016 in United States
The sub-questions are
1) Design where the application executes on single machine.
2) Design where the application can execute on multiple machine.
3) Where could be the potential bottleneck.
4) What component would be bottleneck if 50 cores and slow disk.
5) What component would be the bottleneck if we 4 cores and fast disks.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 design - 2of 2 votes
AnswersYou have two very large numbers that cannot be stored in any available datatypes. How would you multiply them?
- confused_coder August 08, 2016 in United States
How would you multiply more than two numbers?| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 0of 0 votes
AnswersHow will you implement a dictionary.
- Nascent August 08, 2016 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 0of 0 votes
AnswerDesign a monitoring system for hotel booking site. Proper oops design.
- Nascent August 08, 2016 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 0of 0 votes
AnswersHow do I solve this simple geometrical programming problem?
- axaysd July 30, 2016 in United States
https://s32.postimg.org/sm75dimol/hurdle1.jpg| Report Duplicate | Flag | PURGE
Microsoft SDE1 - 0of 0 votes
AnswersGiven an array: 1,2,3 ,5,8,7,6,9,5,7,3,0,5
- sindhu1690 July 27, 2016 in United States
subarry:5,7
Find the subarray in the large array and return the minimum length and index where you can find the subarray. Note: that the subarray may be present in the large array non-contiguous.
In the above case : the answer is length = 2 and
index = 8| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm - 0of 0 votes
AnswersSuppose you have a matrix in the form of a 2 dimensional array. Write a method to read the rows of the matrix alternatively from right to left, left to right so on and return them as a 1 dimensional array.
- MM July 15, 2016 in United States
for eg:
1 2 3
4 5 6
7 8 9
should return 1 2 3 6 5 4 7 8 9| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
Answershow to restrict creation of object inside the function fun
- jkl June 19, 2016 in India
although destructor and constructor is private??
#include <iostream>
class ABC
{
private :
~ABC()
{
}
ABC()
{
std::cout <<"ABC";
}
public:
static void fun()
{
ABC t;
}
};
int main()
{
ABC::fun();
}| Report Duplicate | Flag | PURGE
Microsoft abc - -2of 2 votes
AnswersGiven a matrix which is spirally sorted. Remove an element and insert another element maintaining the sorted order.
- neer.1304 June 14, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven two sets of strings A and B. Find the
- neer.1304 June 14, 2016 in United States
(A-B) U (B-A) ( U = union ). The answer should be in lexicographical order and A’s elements should appear before B’s.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswerGiven a few points in first quadrant – (x1,y1) …..(xn,yn) and given another set of points (a1,b1…..an,bn), determine whether all the points (a1,b1…an,bn) have already occured in (x1,y1)…..xn,yn)
- neer.1304 June 14, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven a graph where every two nodes are either friends or enemies with each other. Find a way to go from one node to the other.
- neer.1304 June 14, 2016 in United States
Restrictions:
1) You can also travel from one node to next if they are friends with each other
2) You have some “magic potions”. You can convert an enemy path to a friend path with a magic potion.
Find the path with min number of magic potions required.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersYou are given a structure msg
- neer.1304 May 24, 2016 in United States
struct msg
{
long timestamp;
double price;
string label;
};
The msg represents price of a stock on a given timestamp.
Create a class with two functions -
addStockPrice(msg m) -> Used to add Stock Price in Data structure
getAvgPriceForAStockLast10Minutes(String stockName) -> Get average price of a stock for last 10 minutes.
The program should be time and space optimized.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersDesign and Implement: Producers and Consumer Problem. Producers produce different kind of messages and Consumers register themselves for different kind of messages. Need to design and implement Producer, Consumer and a Delegator which is responsible for storing and delivering the messages to appropriate listeners.
- neer.1304 May 12, 2016 in United States
Changed the question to handle millions of messages.
Changed the question to handle different priority messages.
Threading model for Producer, Listener and Delegator.
In the end he asked me to code 2 methods of Delegator.
1: which adds the message from Producer to its internal queue.
2: Delegate, which delivers the message to appropriate listener.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Software Design - 1of 1 vote
AnswersThis is a question I received in an online challenge.
- sparked12345 April 22, 2016 in United States
A list of numbers are given. We need to find the total number of groups in which the digits of each number have same frequency.
For example if numbers are:
1
10
3
33
There are 4 groups:
G1={1}has one 1.
G2={3} has one 3.
G3={10}has one 1 and one 0.
G4={33}as two 3s.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - 0of 0 votes
AnswersFind out if there is cycle in Directed graph
- pc April 09, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Algorithm Data Structures - -1of 1 vote
AnswersGiven billions of Rectangle, find rectangle with minimum area overlapping to a given point P(x,y)
- pc April 09, 2016 in United States
There is a simple way to achieve answer in O(n) by processing each rectangle sequentially, but optimize it further provided large number of Rectangle array.| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Algorithm Data Structures