## Microsoft Interview Questions

- 0of 0 votes
Given a wall, which is made up of two types of bricks (Porus / opaque ). Porus bricks allow water pass through them. Opaque won't. Find whether water reaches to ground, if there is any rainfall.

Water can flow from top to bottom, diagonally, horizontally as well. Only flowing from bottom to top is not possible.

- 1of 1 vote
Give an positive integer n, find out the smallest integer m, such that all digits in m multiply equals to n. For example, n = 36, return 49. n = 72, return 89. You can assume there is no overflow.

- 0of 0 votes
Find Duplicate number from a huge amount of data which cannot fit in the memory.

- 0of 0 votes
Find kth-largest number from a huge amount of data which cannot fit in the memory.

- 0of 0 votes
We have an array if 0's and 1's like

00010000010001001

Assume that all 1's are a person and if a new person comes and if we want to add to the array in such a way that the gap between individuals are maximum as possible.

if we add a new person, then the new array should be

000100100010001001

- 0of 0 votes
Evaluate infix expression: 2 + 3 * 5

- 0of 0 votes
Interleave two singly linked lists into one.

LL1: 1 -> 2 -> 3 -> 4

LL2: 10 -> 20 -> 30 -> 40 ->50

Output LL1: 1-> 10 -> 2 -> 20 -> 3 -> 30 -> 4.

Note: Stop when we hit null for LL1.

- 0of 0 votes
You need to design a new YouTube feature where userA is uploading a video and userB (friend of userA) gets notified for the video and wants to watch the same video in real time (i.e. even the video is not completely uploaded but we want to enable the other user to watch it).

How would you tackle the situation when userB wants to view the content starting from a position which is not yet uploaded.

Draw block diagram for this problem identifying the different components.

- -1of 1 vote
Design calculator and related class, which returns result of the given expression, e.g if input is (3* 3) + 2 it returns 11.

Identify different OOPS classes and how would you call them.

- 1of 1 vote
A bus has to travel from A to B and the distance is d miles. There are many gas stations between A and B.

The bus has initially g gallon of gas in tank. 1 gallon of gas travels 1 mile.

Gas stations have inforamtion of remaining distance from station to destination b and max gas that can be filled from the station.

Find the minimum number of stops for bus without running out of gas ever.

eg: gas = 10 , distance = 20

gasStation[] = {{16,3}, {10, 7}, {14, 11},{11, 5}, {7, 6}}

o/p = 1

If bus stops at the stop{14,11} that is 14 miles away from destination and fills 11 gallon then it can reach destination with 1 gallon spare.

It can also stop as {16,3} and {10,7} but its 2 stops and at destination it runs out of gas.

Similarly {11, 5}, {7, 6} has 2 stops but has 1 gallon spare at destination.

- 0of 0 votes
Write a word processor that can do left and right justification for a sample input of string type.

Here is an example:

This is a sample.This is a sample.This is a sample.

This is a sample.This is a sample.This is a sample.This is a sample.

Additional details:

* The left margin is 5 units.

* The right margin is 75 units.

* The input string is a single-spaced collection of words and punctuation.

* If the length of the word exceeds the right margin, then we must not break the word. Instead, we must print it on the next line and justify the existing line by adding more spaces to the middle of the line.

- 0of 0 votes
Given a 3x3 tic-tac-toe board with players 1 and 2. Find all the possible ways player 1 can lose given a particular configuration of the board.

For example (0 denotes empty spot):

input:

0, 1, 0

2, 2, 1

1, 1, 2

Output: 1 (because the only move for player 2 to win would be to play board[0,0])

The input board can have any configuration (player 1 and 2 can be in all possible spots with any number).

- 0of 0 votes
Design a data structure which reads below block of text

*Status update1

**Joe is working on a bug

**Alice is on vacation

*StatusUpdate2

**Alex finished task1

and returns me an Object such that I can navigate the this nested text easily like this:

obj.children[0] - > returns "StatusUpdate"

obj.children[0].children[1] -> "Alice is on vacation"

- 0of 0 votes
Given a Tree where each node contains an attribute say color(R,G,B... etc). find subtree with maximum number of attributes.

Input:

G

/ \

B R

/ \ / \

B B R R

/ \ / \

B R R R

Output:

Input:

R

/ \

R R

\ / \

R R R

- -1of 1 vote
The best project you have worked till now.

- 0of 0 votes
Convert an Integer to a String.

eg 10--->"10",

2.5--->"2.5"

+10--->"+10"

-10----->"-10"

1.25e-7--->0.000000125

- 0of 0 votes
Given n line segments, find if any two segments intersect

http://www.geeksforgeeks.org/given-a-set-of-line-segments-find-if-any-two-segments-intersect/

- 3of 3 votes
Congrats on aonecode.com member V.S. on the offer from Microsoft and thanks for sharing with us the experience.

Coding Question 1 - Find all the paths between two nodes

Coding question 2 : Max sum in adjacent sub array

Design Question - Design a ticketing System

Design Question 2 - Design a system which allows multiple agents to read different data from same tables. Latency should be low. Algorithm should rank agents through some logic and assigned work according to that so that each agents are reading different set of rows from same table. Scale it for 20 million active agents .

Follow up - If Data Sharding is allowed, what will be the Shard Id and how the partition will look like? How your system will respond if there are agents which are also writing at same time. Consistency should be given high preference over availability.

Looking for coaching on interview prep?

Visit AONECODE.COM for ONE-TO-ONE private lessons by FB, Google and Uber engineers!

Customized course covers

System Design (for candidates of FB, LinkedIn, AMZ, Google & Uber etc)

Algorithms (DP, Greedy, Graph etc. every aspect you need in a coding interview & Clean Coding)

Interview questions sorted by companies

Mock Interviews

Our members got into G, U, FB, Amazon, LinkedIn, MS and other top-tier companies after weeks of training.

Feel free to email us aonecoding@gmail.com with any questions. Thanks!

- 0of 0 votes
3. Complete the following function-

Node * alternateReverse( Node* head1, Node*head2){

// code goes here

}

Where ‘Node’ is the structure of a linked list node defined as:

struct Node{

int data;

struct Node *next;

};

alternateReverse() must remove the even number nodes from the linked list and append them to the end in reverse order. No extra space was allowed. It was for 5 marks.

Example:

Input-1->2->3->4->5->6

Output-1->3->5->6->4->2

Input-1->2->3->4->5->6->7->8->9

Output-1->3->5->7->9->8->6->4->2

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

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

- 2of 2 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.