Microsoft Interview Questions
- 0of 0 votes
AnswersDesign class structure for a building, floors and space. The space can be an apartment, a store or an office. Include any properties, fields and methods you think would be interesting to have.
- Purushotham Kumar June 18, 2013 in Ireland for Microsoft Ireland intern recruitment team| Report Duplicate | Flag | PURGE
Microsoft Intern - -1of 1 vote
AnswersGiving a 2D (N*N) Matrix of characters, construct every possible words out of it. A cell in the matrix can only be used one time.
- xgameprogrammer June 17, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersPrint the actual phone number when given an alphanumeric phone number. For e.g. an input of 1-800-COM-CAST should give output as 18002662278 (note: output also does not contain any special characters like "-").
- Jeanclaude June 16, 2013 in United States for Windows Phone| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Hash Table - -1of 1 vote
AnswersIs this even possible? Move the spaces to the starting of the string in a c style string. In place within one iteration.
- madzig June 14, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 13of 19 votes
AnswersWrite a program to find whether a given number is a perfect square or not. You can only use addition and subtraction operation to find a solution with min. complexity.
- Purushotham Kumar June 12, 2013 in Ireland
i/p : 25
o/p : True
i/p : 44
o/p: False| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersWrite a program to reverse a sentence in a zigzag order.
- Purushotham Kumar June 09, 2013 in Ireland
i/p: I am a software programmer
o/p: programmer erawtfos a ma I| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
AnswersFind the first non repeating character in a given string. You may assume that the string contains any character from any language in the world, for e.g. an Arabic
- Jeanclaude June 09, 2013 in United States for Windows Phone
or Greek character even.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - -1of 3 votes
Answerswrite a sample code to find no of 'a' words in a sentence?
- raghuram2404 June 07, 2013 in India
Eg: If a sentence is given as "I found an apple in a tree."
The output is : 1 (not 2)
We have to count no of words.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 5of 5 votes
AnswersIf a linkedlist is having loop, how to find the last node of the loop .
- zammer May 28, 2013 in India for SDET| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - -4of 4 votes
AnswersA large character array is there in which there are spaces in between the character like ab c d ...etc
- zammer May 28, 2013 in India for SDET
Write a method to search any character in the above array in O(n).| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 2of 2 votes
AnswersGiven a list of n points in 2D space. Lets call them (X1,Y1), (X2,Y2) .... (Xn,Yn). Find the optimal way to retrieve the result of following query.
- Amm Sokun May 22, 2013 in India
SELECT min(X) FROM (2D Points) WHERE Y between Ymin and Ymax.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - 1of 1 vote
AnswersCode to check if a given short string is a substring of a main string. Can you get a linear solution (O(n)) if possible?
- Jeanclaude May 18, 2013 in United States for Office| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 0of 2 votes
AnswersGiven a circular linked list, find the mid element of the linked list.
- nightingale May 17, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 2of 2 votes
AnswersSort an array which only has 0's and 1's. Do not use count sort.
- CodeNameEagle May 10, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm Arrays - 0of 0 votes
AnswersQ1. What is inheritance
- JSDUDE May 04, 2013 in United States
2. Polymorphism
3. Diff between Pure Virtual class and Virtual Class
4. Adv and dis-adv of C# and C++ over each other
5. Sequence in which constructors are called when a child class object is created and why is the order so.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Object Oriented Design - 1of 1 vote
AnswersGiven a rotated sorted array, find the MIN of the array.
- JSDUDE May 04, 2013 in United States
He pointed out a mistake in my
int middle = (begin+end)/2 which could overflow if the array size was INT_MAX.
Answer was:
middle = (end-begin)/2 + begin| Report Duplicate | Flag | PURGE
Microsoft SDE1 Arrays - 2of 2 votes
AnswersGiven a binary tree, print its perimeter:
- JSDUDE May 04, 2013 in United States
node, left->most nodes from top to bottom, leaf nodes from left-> right, right->most nodes from bottom to top
----------------------------1
-----------------------2--------3
------------------4-----5-----6--------7
-------------8------9-----10------11-----12
should print:
1-2-4-8-9-5-10-11-12-7-3
5 because it doesn't have any children. 10 and 11 are children of 6 and 8 & 9 are children of 4.
Apologies for the messy diagram.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 0of 0 votes
AnswersGiven a Binary tree and a node, return it's post-order predecessor
- JSDUDE May 04, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 0of 0 votes
AnswersSingle Initialization :
- JSDUDE May 04, 2013 in United States
Global variable x, initialized to 0.
Implement a function that can be called by multiple threads simultaneously or sequentially.
The value of x should be set to the current time only once. If it is already set, the value shouldn't be updated.
Make sure that the function doesn't become a bottleneck| Report Duplicate | Flag | PURGE
Microsoft SDE1 Threads - 0of 0 votes
AnswersGiven a BT and 2 nodes, find LowestCommonAncestor
- JSDUDE May 04, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 2of 2 votes
AnswersFind the Max sum subsequence in array
- JSDUDE May 04, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 Arrays - 0of 0 votes
AnswersGiven 'n' coins, print the number of ways to form an amount 'A' . This is a standard denomination problem with one small twist(We have only one coin of each type,not infinite number,if we choose one coin for making change we should not choose it again) . Can somebody give a code with explanation ?
- Avenger May 02, 2013 in India for Bing
Example:
Amount:3 coins : 1 2 3
There are only two ways (1,2)(3) not (1,1,1)(1,2)(3)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite a program to calculate Sum of two singly linked lists.
- shaktiman April 30, 2013 in -
e.g.
1-->2-->3
8->9->10
.
Result list should be 10-->2-->3
You are not allowed to make any change in input lists. Those are read only.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersGiven a BST find Ceiling value of given key
8 6 12 2 4 11 14
key = 8 return 11
- JSDUDE April 27, 2013 in United States
key = 1 return 2
key = 16 return Null
Iteration and Recursion both| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 1of 1 vote
AnswersQ:
Given a binary tree with nodes that have left, right pointers pointing to the left and right children respoectively. It also has a neighbor pointer that currently Points to null.
Write a function to make it point to its neighbor.
E.g1 2 3 4 5 6 7
1.sibling should point to null
- JSDUDE April 27, 2013 in United States
2.sibling should point to 3
3.sibling should point to null
4.sibling should point to 5
5.sibling should point to 6
6.sibling should point to 7
7.sibling should point to null
Iteration and Recursion both| Report Duplicate | Flag | PURGE
Microsoft SDE1 Trees and Graphs - 1of 1 vote
Answers4 men- each can cross a bridge in 1,3, 7, and 10 min.
- Abhinav April 27, 2013 in United States for MS office
Only 2 people can walk the bridge at a time. How many min. minutes would they take to cross the bridge.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Brain Teasers - 2of 2 votes
AnswersThe probability of a bus passing through a certain intersection in a time window of 20 min. is 0.9
- Abhinav April 27, 2013 in India
What is the probability of the same bus passing through the same intersection in 5 min.| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Probability - 0of 0 votes
AnswersSuppose we want to convert one string S1 to another string S2 using only 3 types of operations:
-Insert(pos,char) (costs 8)
-Delete(pos) (costs 6)
-Replace(pos,char) (costs 8)
Find the sequence of steps to convert S1 to S2 such that the cost to convert S1 to S2 is minimum.
Eg. 'calculate' to 'late' - the possible operations are
Delete(0)
Delete(1)
Delete(2)
Delete(3)
Delete(4)
and the above sequence of operations costs 30.
I used the following code(using levenshtein algorithm) to solve this. But I am not getting correct answer.
- bond April 23, 2013 in United Statestuples=[] ops=[] s1='' s2='' def levenshtein(a,b): global s1,s2 n, m = len(a), len(b) if n > m: a,b = b,a n,m = m,n s1,s2=a,b current = range(n+1) for i in range(0,len(current)): current[i]=current[i]*8 tuples.append(current) for i in range(1,m+1): previous, current = current, [i*8]+[0]*n for j in range(1,n+1): add, delete = previous[j]+6, current[j-1]+8 change = previous[j-1] if a[j-1] != b[i-1]: change=change+8 current[j] = min(add, delete, change) tuples.append(current) return current[n] print levenshtein('calculate','late') for i in range(len(tuples)): stri='' for j in range(len(tuples[0])): stri+=str(tuples[i][j])+' ' i=len(tuples)-1 j=len(tuples[0])-1 ops=[] while i>0: while j>0: minimum=min([tuples[i-1][j],tuples[i][j-1],tuples[i-1][j-1]]) if minimum==tuples[i-1][j]: i=i-1 if not tuples[i][j]==tuples[i-1][j]: ops.append([1,i]) elif minimum==tuples[i][j-1]: j=j-1 if not tuples[i][j]==tuples[i][j-1]: ops.append([2,i-1,j]) else: ops.append([3,i-1,s1[i-1]]) i=i-1 j=j-1
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 4of 4 votes
AnswersImplement a simple regex parser which, given a string and a pattern, returns a boolean indicating whether the input matches the pattern. By simple, we mean that the regex can only contain one special character: * (star). The star means what you'd expect, that there will be zero or more of any character in that place in the pattern. However, multiple consecutive stars are allowed. Some examples of valid input (and expected output):
- DJ April 20, 2013 in United States
f(a*b, acb) => true
f(abc*, abbc) => false
f(**bc, bc) => true| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Coding