Microsoft Interview Questions
- 0of 0 votes
AnswersIt’s a two player game. Both the players are equally intelligent to win the game. Give n no. of stones. A player can choose either 1 stone or k stones or l stone (1<k<l). Suppose player 'A' starts game then challenge was to identify the player who will win the game. Player who picks the last 1 stone or last k stone or last l stones win the game.
- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswerDesign bus booking system:- Each row has x seat. If customer wants K seats if you have K consecutive seats available, reserve them. Otherwise give seats from any row.
- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersThere is a bridge and N no. people takes (a1,a2,—an) time to cross it and there are K torch and at any time x no of people can pass the bridge and it takes maximum of x people time to cross it. Minimum time required for N persons to cross the bridge.
- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswerThere is a graph where each node represents a city and it contains specific no. of people. A tournament is going on and each match is playing in one city. All city’s people gather to watch match. Traffic department wants to manage how many people travel through city x if match is playing in city y for each x. City x and y can be any city.
- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGot Sp00ked by MS simple question..
- hprem991 August 29, 2017 in United States
Eight Ball problem, find Minimum steps to determine the heaviest one.
Anyone know the answer is 2 in case of 8 balls.. Question is code getHeavy when number of balls are not determined.
int getHeavy(List<Integer> balls){
// Your solution
}| Report Duplicate | Flag | PURGE
Microsoft SDET - 2of 2 votes
AnswersDesign a mall where there are 'm' entry gates and 'n' exit gates. There can be only 'x' number of people inside it. No more then 'x' people can be inside mall at any time.
- neer.1304 July 30, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Software Design - 0of 0 votes
AnswersHow will you design a true collar?
- Nascent July 27, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 0of 0 votes
AnswersGiven an array of co ordinates (x,y). WAP to figure out if a square can be formed from any four points.
- Nascent July 27, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 0of 0 votes
AnswersGiven a 2d matrix and 4 points. WAP to figure out if they are row wise, column wise of diagonally wise consecutive.
- Nascent July 27, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 9of 9 votes
AnswersFind the number of ways you can have breakfast in 'n' days, given Bread-butter can be eaten every day, Pizza can be eaten every alternate day and Burger can be eaten every two days.
- gopalakshintala June 19, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Dynamic Programming - 0of 0 votes
Answer/*Find minimum size of text window which contain all keywords of a search query from document.
- npkatre104 June 16, 2017 in United States
Order of keywords don't matter.
Input:
Document: "MS(1) x y Is MS(5) x y MS(8) x Is Awesome x y z Awesome"
doc index dictionary:
{
Keyword: Index Position for keyword in doc
"MS": [1,5,8],
"Is": [4,10]
"Awesome": [ 11, 15] (n)
}
Search Input 1 : "MS is" ( k)
Result: "Is MS Ms" --> [Ms: 5 ; "Is" : 4] --> 2
Search Input 2: "Ms is Awesome",
Result : "MS x is Awesome" --> [Ms:8, Is: 10, Awesome: 11] ---> 4
for -> n
n^k
[1 4 5 8 10 11 15]
*/| Report Duplicate | Flag | PURGE
Microsoft Solutions Engineer - 0of 0 votes
AnswersDesign an IEvictionPolicy interface that allows users to perform put , get, delete functions based on user specified eviction policy.
- mesmerizing.memories89 June 16, 2017 in United States
Tried to use the strategy pattern here but the interviewer wasn't happy. He did not want me to have reference to the cache in the eviction policy's concrete implementation| Report Duplicate | Flag | PURGE
Microsoft - 1of 1 vote
AnswersFor a given Sum and N print all the combinations
For Example Sum = 16 and N=2
Then Answer :
16,0
15,1
14,2
13,3
12,4
11,5
10,6
9,7
8,8
7,9
6,10
5,11
4,12
3,13
2,14
1,15
0,16private void recursivePrint(int sum, int n, int data[], int len, int originalSum) { if (n == 0) { int sum1 = 0; for (int j = 0; j < len; j++) { sum1 += data[j]; } if (sum1 == originalSum) { for (int j = 0; j < len; j++) { System.out.print(data[j] + " "); } System.out.println(); } return; } for (int i = 0; i <=sum; i++) { // System.out.println(" len: "+len+" sum: "+sum+" i: " + i+" n:"+n) data[len] = i; recursivePrint(sum - i, n - 1, data, len + 1, originalSum); } } }
Need a better solution so that we can store previous results by using hashmaps
- NoMind April 23, 2017 in India for Azure| Report Duplicate | Flag | PURGE
Microsoft Software Developer - 0of 0 votes
AnswerWas asked to implement a code profiler, which takes a piece of code and provides the run time of a particular function in the code .
- Anon April 11, 2017 in United States
If a function is internally calling other functions, we just want to see the time spent executing the original function, and not the overall time.| Report Duplicate | Flag | PURGE
Microsoft - 0of 0 votes
AnswersImplement Thread safe timer with start, stop and reset functionality.
- twarzo March 22, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Threads - 0of 0 votes
AnswersThere are two integer array arrayA and arrayB in the same size and two integer countA and countB. If arrayA[i] > arrayB[i], then we increase countA by 1, if arrayB[i]>arrayA[i], then we increase countB by 1. We will do nothing otherwise. Now you are given arrayA and arrayB, write a function to shuffle arrayA and so you can get countA > countB. Assume the input array are always valid, not empty and the input is guaranteed to have answer.
- gzyeli123 March 20, 2017 in United States
For example:
arrayA = [12, 24, 8, 32]
arrayB = [13, 25, 32, 11]
After shuffle:
arrayA = [24, 32, 8, 12]
arrayB = [13, 25, 32, 11]| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - -1of 1 vote
Answerusing System;
- sunil.sebastian March 16, 2017 in United States
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ArrayProblems
{
public class MultiplyTwoLargeNumber
{
public static string MultiplyBigNumbers(string s1, string s2)
{
char[] num1 = s1.ToCharArray();
char[] num2 = s2.ToCharArray();
//string=99
//char--> 9 , val --> 57(48+9)
//so s[i]-'0' will give val 9 and char as horizontal tab
char[] result = new char[num1.Length + num2.Length]; // Default 0 '/0' 2 ==> 50 '2'
int carry = 0;
int offset = 0;
for (int i = num1.Length - 1; i >= 0; i--)
{
int tail = result.Length - 1 - offset;
for (int j = num2.Length - 1; j >= 0; j--)
{
int resval = 0;
if(result[tail]!=0)
{
resval = result[tail] - '0';
}
int sum = resval+ ((num1[i] - '0') * (num2[j] - '0')) + carry; //remember to add result before taking mode
result[tail] = (char)((sum % 10) + '0');
carry = sum / 10;
tail--;
}
if (carry > 0)
{
int res = (result[tail] != 0) ? (result[tail] - '0') + carry : result[tail] + carry;
result[tail] = (char)(res + '0');
carry = 0;
}
offset++;
}
return new string(result);
}
}
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 2 votes
AnswersThe following code has a bug, find it and fix it
- sergio March 05, 2017 in United Kingdom for BingRelease() { m_refCount--; m.lock(); if (m_refCount == 0) { free(this); return 0; } m.unlock() return m_refCount; }
| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm - 1of 1 vote
AnswersWrite a function that receives a string an returns a list of all the substrings (of length >= 2) composed by consecutive characters. E.g input : "BCCDE" , output: ["BC","CD","CDE","DE"]
- sergio March 05, 2017 in United Kingdom for Bing| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm - 0of 0 votes
AnswersGiven a linked list rotate it on the Kth element. For example, given 1->2->3->4->5 the list should be transformed into 4->5->1->2->3
- sergio March 05, 2017 for Bing| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm - 2of 2 votes
AnswerDesign a stock market system
- nn January 24, 2017 in India| Report Duplicate | Flag | PURGE
Microsoft Intern Software Design - 1of 1 vote
AnswersPrint elements of a matrix in spiral form.
- yasharonline January 12, 2017 in United States for Azure| Report Duplicate | Flag | PURGE
Microsoft SDE1 Matrix - 0of 0 votes
AnswersGiven 2 sorted linked lists, return a linked list that has all the elements and is sorted.
- mh4wt@virginia.edu January 09, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java - 0of 0 votes
AnswerGiven 3 strings "s" ssearch" and "sreplace", search string s for the substring ssearch and for every instance of ssearch you find, replace that part of the string with sreplace
- mh4wt@virginia.edu January 09, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java - 0of 0 votes
AnswersGiven an NxN Boolean matrix, find how many true regions there are in the matrixj
- mh4wt@virginia.edu January 09, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java - 0of 0 votes
AnswersCreate a basic minesweeper game that allows for board creation with custom height, width and number of mines. Create a <click> function that will take in a board location and return whether the user has won, lost, or the number of surrounding mines.
- mh4wt@virginia.edu January 09, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java - 0of 0 votes
AnswersGiven a string, print out all of the unique characters and the number of times it appeared in the string
- mh4wt@virginia.edu January 09, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java String Manipulation - 0of 0 votes
AnswersWhat is the smallest number *n* by which the given number *x* must be divided to make it into a perfect square?
- NoOne January 08, 2017 in Indian = find_number( x )
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a singly linked list of integers, write a function in java that returns true if the given list is palindrome, else returns false
- mh4wt@virginia.edu December 18, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java Linked Lists