Microsoft Interview Questions
- 0of 0 votes
AnswersDesign a game of Tic-Tac-Toe. Only instead of 3x3, this is a game on n x n board. Two manual players play the game. A player wins if there are all "X" or all "O" in either of n rows, n columns or 2 diagonals. What are the classes and data structure you will define? After each move/turn of a player, it is checked whether the player won the game. Minimize this time. Assume having no space constraint.
- @ce October 24, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Intern - 0of 0 votes
AnswersGiven a positive integer, decode it into a string in following way :-
- @ce October 24, 2012 in India
1 - a, 2 - b,3 - c,...26 - z, 27 - aa, 28 - ab........and so on.| Report Duplicate | Flag | PURGE
Microsoft Intern Coding - 0of 0 votes
AnswersGiven today is Thursday and 23rd August, 2012. Write a function to input a date (future or past) and tell which day it is:-
- @ce October 24, 2012 in India
int day_of_week(int dd, int mm, int yyyy)
Mon -1, Tue - 2, Wed -3......Sun-7| Report Duplicate | Flag | PURGE
Microsoft Intern Coding - 1of 1 vote
AnswersWith a pointer to head node of a linked list as argument, write a function to swap the consecutive elements of the list and return the head node. (Do note change values of any node, only change the links.)
- @ce October 24, 2012 in India
Example :-
1->2->3->4->5->6->7
2->1->4->3->6->5->7| Report Duplicate | Flag | PURGE
Microsoft Intern Linked Lists - 1of 1 vote
AnswersGiven an array of integers, give the most efficient algorithm to find if the array has a majority element. If the array has a majority element, find this element. (Note : The majority element is the element that occurs more than half of the size of the array)
- @ce October 24, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Intern Algorithm - 0of 0 votes
AnswerA screen has different shapes of objects. The number f objects is large like million. We want to zoom into a region on the screen. How can we identify which objects should be displayed in the zoomed area? Give a data structure to store objects.
- gradstudent13 October 23, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Data Structures - 1of 1 vote
AnswersWAP to print the node values of a binary tree
- yakku October 22, 2012 in United States
- Even level starting from right to left
- Odd level starting from left to right
Assume that level of root is 1.
a
b c
d e f g
Output: a c b d e f g| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersAssume you have a integer matrix (m x n) sorted over column wise & row wise. WAP to find the kth smallest element from the matrix.
- yakku October 22, 2012 in India
E.g.
int[][] a =
2, 5, 8, 10
4, 7, 9, 12
6, 15, 20, 22
So 5th smallest element is: 7| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 1of 1 vote
AnswersWrite code to sort an integer array of size N which has only three unique values 0,1,2 duplicated & randomly placed over the entire array.
- yakku October 22, 2012 in India
- Memory used should be O(1)
- Run time should be O(N)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 1of 1 vote
AnswersAssume that a binary tree is drawn over a Cartesian coordinate system (with X & Y axis) where the leftmost node is placed at point (0,0). So, we need to traverse the nodes and print in following manner:
- yakku October 22, 2012 in India
For e.g., for this tree
a
b c
d e f g
Output should be:
d,0,0
b,1,1
e,2,0
a,3,2
f,4,0
c,5,1
g,6,0| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - -1of 1 vote
AnswersFind the angle between the hands of a clock.
- Survy October 21, 2012 in United States for Visual Studio| Report Duplicate | Flag | PURGE
Microsoft Program Manager C - 0of 0 votes
AnswersYou are a startup trying to design a new mobile online music player.
- Survy October 21, 2012 in United States for Visual Studio
(startup => you need to differentiate yourself from the existing music players)| Report Duplicate | Flag | PURGE
Microsoft Program Manager Application / UI Design - 0of 0 votes
AnswersAn airline carrier is losing a lot of bags. You have been assigned to help them out. What would you do?
- Survy October 21, 2012 in United States for Visual Studio| Report Duplicate | Flag | PURGE
Microsoft Program Manager Application / UI Design - -2of 2 votes
AnswersYou are at the center of n*n*n cube if n is odd and somewhere near center if n is even, print all possible paths to reach the surface of the cube
- siva October 18, 2012 in United States for Windows| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
Answers>Compute the number of connected component in a matrix, saying M. Given two items with coordinates [x1, y1] and [x2, y2] in M, M(x1, y1) == -1 && M(x2, y2) == -1 && |x1-x2|+|y1-y2|=1 <=> they are connected
- xiaoc10 October 17, 2012 in United States
Example:
-1 0 -1 0 0
-1 -1 0 -1 -1
0 0 0 0 -1
0 0 0 -1 -1
0 0 0 -1 0
0 -1 0 0 0
0 -1 0 0 0
Output: 4. And they are:
-1
-1 -1
-1
-1 -1
-1
-1 -1
-1
-1
-1
My idea is to scan the matrix.
Initialization:
count = 0.
For every item in the matrix, do the following three tests.
(1) If it's 0, skip
> (2) If it's -1, check its four neighbors. If there is a neighbor whose
value is not 0 and -1, assign the value of this neighbor to the current item. Otherwise, `count++`, ant then assign `count` to the current item.
>
> (3) If it's not 0 and -1, assign the value of current item to its four
neighbors whose value is -1.
Can anyone help me verify this solution?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGive a basic over view of designing a linkedlist in Java
- enthusiast October 16, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - -2of 2 votes
AnswersGiven an Array say, a [0,1,2,6,3,4] and lets say x=5..
- enthusiast October 16, 2012 in United States
Return true for all the values which add up to value of x like 2+3, 1+4 etc; for everything else return false.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersHow do we store data at x(Row),y(column) of an excel sheet into a 1 dimensional buffer of fixed size.
- nr October 15, 2012 in United States
x can be any row and y can be any column..| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a binary tree find the difference in height between the closest leaf to the root and the furthest leaf from the root. You cannot use recursion since the tree is very deep and would cause a stack overflow.
- Tragic Foobar October 13, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an integer array, sort the integer array such that the concatenated integer of the result array is max. e.g. [4, 94, 9, 14, 1] will be sorted to [9,94,4,14,1] where the result integer is 9944141
- siva October 11, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an unsorted array.
- Shobhit October 07, 2012 in United States
With each number, we can associated a sum which is equal to the sum of all the numbers, less than the current number.
We've to find the total sum of all those numbers.
e.g. unsorted array :1, 5, 3, 6, 4.
for a[0]=1, sum[0]=0
for a[1]=5, sum[1]=1
for a[2]=3, sum[2]=1
for a[3]=6, sum[3]=1+5+3
for a[4]=4, sum[4]=1+3
total sum =sum[0]+sum[1]+sum[2]+sum[3]+sum[4] = 15| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersFind the first common ancestor of two nodes in a binary tree (note not a BST).
- singhSahab October 06, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersIn Excel sheet rows are marked using integer numbers like 1,2,3 but the columns are marked using characters. Like A, B and C.
- singhSahab October 06, 2012 in India
so here column 0 = A (assuming column starting with 0)
column 1 = B
column 25 = Z
column 26 = AA
column 100 = CW
Q. Write a program to give the string representation of column for given integer.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a sum find(print) all 2 numbers and their index positions from an un-ordered array that add up the sum value. 1 4 4 3 7 5 8 as array and sum =8 .
- M October 06, 2012 in United States for Server tools division
So here the code should print 1 (index 0) + 7(index 4)
4(index 1)+ 4(index2), and so on..| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
AnswersHow do you test a Calendar? (eg. An outlook calendar or google calendar)
- M October 06, 2012 in United States for Server tools division| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Testing - 0of 0 votes
AnswersGiven an array { -2 3 5 0 -3 7 -1}. Sort the array in such a way that array should contain -ve numbers first and then zero and then all +ve numbers. (Note: order of +ve number and order of -ve numbers should be same after sorting). For ex: the o/p of above array is {-2 -3 -1 0 3 5 7}
- prashaenator October 05, 2012 in India for BING| Report Duplicate | Flag | PURGE
Microsoft Developer Program Engineer Algorithm - 0of 2 votes
AnswersGiven 3 sorted arrays. Find(x,y,z), (where x is from 1st array, y is from 2nd array, and z is from 3rd array), such that Max(x,y,z) - Min(x,y,z) is minimum.
- prashaenator October 05, 2012 in India for BING| Report Duplicate | Flag | PURGE
Microsoft Developer Program Engineer Algorithm - 0of 0 votes
AnswersDesign a Date class that represents a US date. Write add and subtract operation using the class. Optimize the operations.
- k October 03, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding - 1of 1 vote
AnswersGiven an array of integers [2,1,3, 5, 7, 6], re arrange elements such that either even numbers in even locations or odd numbers in odd locations. i.e [2,1,6,5,7,3] in O(n)
- bluesky October 02, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding