Microsoft Interview Questions
- 0of 0 votes
AnswersDesign a class structure for an airport terminal, where your primary use case is allocating runway time to approaching aircraft. For example, an instance of a terminal may have only two runways of different lengths and must schedule these among five aircraft of different types requesting permission to land.
- DJ April 20, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Object Oriented Design - 0of 0 votes
AnswerWrite a service or services to support tic-tac-toe between two players, on an infinite board. Normal rules apply (i.e. three in a row to win), but the players are not limited to a 3X3 board and can choose to place an X or an O in any arbitrary, positive (i, j) position. Solution should be as space and time efficient as possible. Your service is only responsible for maintaining and updating the state of the board between two players, given their sequence of moves.
- DJ April 20, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Coding - 1of 1 vote
AnswersTruth Table implementation: Write a function which takes integer as In put parameter (let's say n), print all True (T) , False (F) combinations n times. Here is the example:
for n = 1
Output :
T
F
for n = 2
Output :
T F
F T
For n = 3
Output :
- Surya April 19, 2013 in United States for Mobile BIT T T T T F T F T T F F F T T F T F F F T F F F
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array of integers, find all sub-arrays whose elements sum zero.
- ANONU April 16, 2013 in India
1.-1,4,-4 has 3 such arrays 1 to -1, 1 to -4 and 4 to -4| Report Duplicate | Flag | PURGE
Microsoft SDE1 - 0of 0 votes
AnswersGiven a mathematical expression, remove the redundant brackets from the expression.
- maverick April 11, 2013 in United States
e.g. input: (a + (b*c)) * (d * ( f * j) )
output should be: (a + b * c) *d * f * J
operations to support: +, -, /, *, ++, also ternary operators.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 1of 1 vote
AnswersWrite a function to populate the best (lowest cost) path in a 64x64 weighted grid from a given start cell to a destination cell.
- hyde666 April 10, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersDesign a task scheduler
- pavi.8081 April 10, 2013 in United States for STB and MVO| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Object Oriented Design - 0of 0 votes
AnswersDesign a vending machine.
- pavi.8081 April 10, 2013 in United States for STB and MVO| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Object Oriented Design - 0of 0 votes
Answersarray of numbers are given. WAP to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.
- pavi.8081 April 10, 2013 in India for STB and MVO
Follow up: After writing program to return the largest sum modify it to return the start and end index of such a subarray.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven an array with source code and braces (braces means '{' or '}' ) intermixed. WAP to return true of braces are balanced (implies that for each opening brace there must be a closing brace and for each closing brace there must be opening brace) and false otherwise.
- pavi.8081 April 10, 2013 in India for STB and MVO| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven a pattern P and a text T, WAP to return all indices from T where P matches.
- pavi.8081 April 10, 2013 in India for STB and MVO| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 1of 3 votes
AnswersPosition of Knight is given on a chessboard.
- pavi.8081 April 10, 2013 in United States for STB and MVO
Return me something (adjacency matrix or list or anything) which shows all
the positions the knight can reach upto from a given position.
I must be able to tell, from what is returned, if the position is reachable or not
and if reachable I must be able to trace the path from given position to target position
<<FOLLOW-UP>>
For example if 4 cells are reachable from a cell A, then these 4 cells become children of A.
Then from a cell, say B, out of these 4 cells, you can reach 2 more cells: C and D. Then C and D become children of B.
Likewise program need to return me a DS. I have given a valuable hint with this follow-up. I hope this will help| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - -2of 4 votes
Answersfind a pattern in byte array and change that pattern in place (do not use temp array or variable)
for example, find pattern 0,0,3 in an byte array and replace it with 0,0
should be o(n)
my solutions :
- SDguy April 03, 2013 in United StatesByte*remPattern003(byte arr[] , int &size) //size is input and output variable ///outputs size of output array { int k = 0; for(int i=0;i<size;) { if(arr[i] == 0 && arr[i+1] == 0 && arr[i+2] == 3) { arr[k++]=arr[i]; arr[k++]=arr[i+1]; arr[k]=arr[i+3]; i+=3; } else arr[k++]=arr[i++]; } size= k; return arr; }
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Arrays - -1of 3 votes
AnswersWrite a method that can sort an array of items that can be compared with each others.
- GodOfCode March 30, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - -1of 3 votes
AnswersDesign and code a way to suggest predictions for your query as you type in real time (such as Google Instant).
- GodOfCode March 30, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - -1of 3 votes
AnswersDesign and code a way that Facebook could use to suggest new friends you might know.
- GodOfCode March 30, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 1of 3 votes
AnswersIs this code working fine ? if yes/no give reason ?
- goelrinku90 March 29, 2013 in India
#include<iostream>
using namespace std;
struct node
{
int a;
int b;
};
typedef struct node Node;
void swap(void *a,void *b)
{
void *temp;
temp=a;
a=b;
b=temp;
}
int main()
{
Node *a1,*b1;
a1=(Node*)malloc(sizeof(Node));
b1=(Node*)malloc(sizeof(Node));
a1->a=10;
a1->b=20;
b1->a=30;
b1->b=40;
cout<<a1->a<<" "<<a1->b<<endl;
cout<<b1->a<<" "<<b1->b<<endl;
swap(a1,b1);
cout<<a1->a<<" "<<a1->b<<endl;
cout<<b1->a<<" "<<b1->b;
}
I surprised to see the ans after compiling this code ... i think u enjoy this code... :)| Report Duplicate | Flag | PURGE
Microsoft Software Development Manager - 0of 0 votes
AnswersHow to check if a binary tree is a binary search tree?
- SkyClouds March 26, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test 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 - 0of 0 votes
Answers5. There Are N Coins On A Table. There Are Two Players A&B. You Can Take 1 Or 2 Coins At A Time. The Person Who Takes The Last Coin Is The Loser. A Always Starts First.
- Abhijit March 21, 2013 in India
1. If N=7, Then
A) A Can Always Win By Taking Two Coins In His First Chance.
B) B Can Win Only If A Takes Two Coins In His First Chance.
C) B Can Always Win By Proper Play.
D) None of the Above.
2. A Can Win By Proper Play If N Is Equal To
A) 13 B) 37 C) 22 D) 34 E) 48
3. B Can Win By Proper Play If N Is Equal To
A) 25 B) 26 C) 32 D) 41 E) None
4. If N<4, Can A Win by Proper Play Always?Answer: Yes.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Brain Teasers - 0of 0 votes
Answersfrom given array of n elements find the maximum element for each consecutive sub-array of k elements.
- goelrinku90 March 19, 2013 in India
eg.
array=[6,5,4,3,2,1]
k=3
ans=6 5 4 3
explanation:-
6 from array [6,5,4]
5 from array[5,4,3]| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite a program in C to read all the characters from standard input and output the reverse when the user presses enter key.
- Expressions March 19, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersWrite a program in C to do run length encoding of an string in place. Desired space complexity O(1).
- Expressions March 19, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 4of 6 votes
Answersgiven an int array with no duplicate numbers, write a function to return number of ways to calculate a target number.
- cooldog March 15, 2013 in United States
example: given {2,4,6,8} Target = 12
2 + 4 + 6 = 12,
4 + 8 = 12,
6 + 8 - 2 = 12,
2 - 4 + 6 + 8 = 12,
return 4| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Software Engineer in Test - 0of 0 votes
Answersdifference between hashtable and hashmap in C#?
- sg March 15, 2013 in United States
when to use hashtable, list, hashmap and dictionary.| Report Duplicate | Flag | PURGE
Microsoft - 0of 0 votes
AnswersGiven coordinates (X[i],Y[i]) of all the cities in the world(for simplicity lets consider we have 2D world map). You are given a user's location (x,y), find out the closest city to the user. Write code for it.
- HauntedGhost March 09, 2013 in United States
Update:
Time complexity of the solution should be better than O(n) as there will be multiple lookup queries with different input points.
You can preprocess the data in any way you like, but you need to minimize the query execution time complexity.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersImplement memcpy function which accepts num of bits as argument as oppose to number of bytes.
- codomania March 07, 2013 in United States for Windows Phone
memcpy (src, dst, num_bits)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Bit Manipulation - 2of 2 votes
AnswersArrange 1 to N in random order with no duplication.
- codomania March 07, 2013 in United States for Windows Phone| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays