## Microsoft Interview Questions

- 0of 0 votes
What is the Big O of that algorithm? What happens at runtime?

- 0of 0 votes
What's the algorithm to transform the sentence "the brown fox ran fast" in "eht nworb xof nar tsaf" (reverse any word)

- 0of 0 votes
Write a program to shuffle a deck of card?

- 0of 0 votes
Suppose you have a stock broker events that send events whenever there is an event occurs, like buy, sell etc.

There are apps that needs gets these data from the events application, not all application needs all the functions.

There is broker interface that is a link between the apps and the stock application. How will you design the classes, methods etc.

- 0of 0 votes
Supposed you have a sorted array, that was rotated like [2 4 6 7 8] => [7 8 2 4 6]. How will find an element in the array.

- 0of 0 votes
Consider a social networking site, where in each user has a number of contacts, how will you find the shortest path between 2 users who are not connected.

- 0of 0 votes
Given list of line segments({x_start, y_start}, {x_end, y_end}) find out the maximum number of points they intersect. (interviewer said, he can make it simpler by assuming only vertical or horizontal lines with no overlapping lines)

Givenen tree in which each node has (or grows) exactly 4 children with values (2, 2.5, 8, 50) plus the value of its parent node. Find out the least K values.

e,g, k = 5, node with value 2, 2.5, 4, 4.5, 6

- 0of 0 votes
List of processes with start time, end time and bandwidth. Find the maximum bandwidth for the list.

2. Given N teams which need to play each other exactly once but at most once in one day, output the game schedule.

- 0of 0 votes
Snake and ladder game. Given a board state with position information for snakes and ladders, find the minimum number of ways(aka dice throws) one can reach from start to end.

- 0of 0 votes
Longest substring palindrome

(interview looking for n^2 or less solution)

- 0of 0 votes
write a function to check if a given number is super-prime.

you are given a function that checks if a number is prime.

super-prime is a number that both it's prefix AND suffix are prime number.

The solution has only one loop.

- 0of 0 votes
Given a root to a binary tree, find the level of the tree with the minimum sum.

for example:

50

/ \

6 2

/ \ /

30 80 7

the answer is: level 2

- 0of 0 votes
Design a system which helps to calculate average Skype call duration per day. In which events are tracked from mobile app. Need to take care of all edge cases like events can be logged to server in any sequence & there can be some events missing on server side also.

- 0of 0 votes
Given a very large binary number which cannot be stored in a variable, determine the remainder of the decimal equivalent of the binary number when divided by 3. Then generalize to remainder of any number 'k'

- 1of 1 vote
Given a pre-order traversal, construct a binary search tree in O(n) time.

- 0of 0 votes
Given a large text file, find an efficient algorithm to find the least distance(measured in number of words) between any two given words.

- 1of 1 vote
You are given a text file. You have to return the list of starting index of the given word in text file. Design an efficient DS for that.

Example :-

Text file content : “geeks for geeks”

word : “geeks”

List : {0,10}

- 0of 0 votes
In a file, there are two columns, first column has some word (String) and 2nd column has some value (Double).

Example :-

ABC 23.4

ERF 34.89

WERT 122.9

Now user wants some arithmetic operations like

1) ABC + ERF = 23.4 + 34.89 = 58.29

2) ABC – WERT = 23.4 – 122.9 = -99.5

Design an efficient DS for these kind of operations.

- 0of 0 votes
Implement a queue using only one stack.

- 0of 0 votes
It’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.

- 0of 0 votes
Design 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.

- 0of 0 votes
There 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.

- 0of 0 votes
There 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.

- 0of 0 votes
Got Sp00ked by MS simple question..

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

}

- 1of 1 vote
Design 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.

- 0of 0 votes
How will you design a true collar?

- 0of 0 votes
Given an array of co ordinates (x,y). WAP to figure out if a square can be formed from any four points.

- 0of 0 votes
Given a 2d matrix and 4 points. WAP to figure out if they are row wise, column wise of diagonally wise consecutive.

- 0of 0 votes
Find 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.

- 0of 0 votes
/*Find minimum size of text window which contain all keywords of a search query from document.

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]

*/