Microsoft Interview Questions
- 0of 0 votes
AnswersHas anyone interviewed with Microsoft, Fargo North Dakota? Care to share the experience and some interview questions?
- Glorious May 20, 2019 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswersYou are given a set of functions:
int open_port(); opens a serial port and returns 0 if everything ok (or -1 if error) int read_port(char *buf, int buf_size) which reads data from a serial port and stores it to 'buf' of size 'buf_size' or blocks until the data is available and returns the number of bytes read (or -1 if error occurred) void close_port(); closes a serial port connection
Design a class:
class SerialConnection { public: using ByteHook = std::function<void(char)>; SerialConnection(ByteHook callback); .... };
which should read data from the serial port asynchronously and send it to the callback function ByteHook byte by byte (e.g., for decoding).
- pavel.em August 24, 2018 in United States
Note that if you don't call 'read_port' often enough, the underlying system buffer might get full and some bytes will get lost..
Which data structures / sync primitives you are going to use ?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Coding - 2of 2 votes
AnswersQuestion : Given a set of N numbers [1,N], partition them into 2 disjoint subsets based on a set of K queries.
- robb.krakow July 25, 2018 in United States
Each query is of the type (n1, n2) where n1 and n2 are distinct numbers from the set and n1 and n2
belong to opposite subsets.
Example:
Input:
Input:
N = 4
K = [(1, 2), (1, 3), (2, 4)]
Output:
Set 1 : (1,4)
Set 2 : (2,3)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Data Structures - 2of 2 votes
AnswersGive 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.
- aonecoding June 06, 2018 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 7of 7 votes
AnswerEvaluate infix expression: 2 + 3 * 5
- annu025 March 21, 2018 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswersInterleave two singly linked lists into one.
- annu025 March 21, 2018 in United States
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.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 3of 3 votes
AnswersCongrats on aonecode.com member V.S. on the offer from Microsoft and thanks for sharing with us the experience.
- aonecoding December 02, 2017 in United States
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!| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 0of 0 votes
AnswersGiven 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)
- bottomcoder October 13, 2017 in United States
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| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswersList of processes with start time, end time and bandwidth. Find the maximum bandwidth for the list.
- bottomcoder October 13, 2017 in United States
2. Given N teams which need to play each other exactly once but at most once in one day, output the game schedule.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswersSnake 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.
- bottomcoder October 13, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswersLongest substring palindrome
- bottomcoder October 13, 2017 in United States
(interview looking for n^2 or less solution)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 1of 1 vote
AnswersIf you have 1TB of unsorted long integers but 1GB of memory, devise an algorithm to efficiently sort the integers. What is the time complexity? What is the space complexity?
- popeye123 January 29, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 3of 3 votes
AnswersGiven 4 teams and 3 gamedays, create an algorithm such that each team plays another team every gameday and by the end of the 3 game days each team should have played one game with every other team.
- popeye123 January 03, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm Problem Solving - 0of 0 votes
AnswersGiven an array of ints (positive numbers) find out the index that balances the array. If no such index exists, return the index that minimizes the difference.
- tamashionuth January 02, 2016 in United States
How can you do it by touching each element only once.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 0of 0 votes
AnswerInsert an int into a circular single linked list.
- tamashionuth January 02, 2016 in United States
Discuss corner cases: what if the element to be inserted is the smallest, how can we speed things up (e.g. if the method is called multiple times you can keep track of the "last"/greatest element).
Thorough testing discussions.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 0of 0 votes
AnswersHow to sort a very large array (>50GB int array) stored on disk given that you have a 200MB RAM memory.
- tamashionuth January 02, 2016 in United States
Discussions on this: test it, corner cases, etc.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 2of 2 votes
AnswersGiven a number (integer) as a string turn in into a number:
- tamashionuth January 02, 2016 in United States
E.g. "One million two hundreds thousands fifty seven" => shoud return 1200057.
How to model it and how to test it? What data structures would you use. Deep testing (corner cases)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 1of 1 vote
AnswersGiven a number N, write all possible sums of consecutive numbers that add up to N.
- tamashionuth January 02, 2016 in United States
That is:
return all pairs (a, k) such that a+(a+1)+...+(a+k)=n
After that:
1. what if N is negative or a is negative;
2. what if N is real and the possible implications of this| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 0of 0 votes
AnswersHow would you convert a row number on Excel to a label? Rows are labeled alphabetically with letters added on once the alphabet has been fully used. (Ex. row # 5 is labeled E, row # 27 is labeled AA, row # 28 is AB, row # 53 is BA and so forth) What would the row label be for a large number, such as 1500?
- popeye123 January 02, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Problem Solving - 0of 0 votes
AnswersGiven an array of five integers that represents a poker hand e.g. [2,2,2,3,3] return the value of the hand, valid values are only "pair","two pairs","three of a kind","full house","four of a kind" we don't have to worry about straight, flush or straight flush.
- DanOG99 December 15, 2015 in United States
My approach was to have a fixed array of 13 elements (each element represents one possible value of the hand) this array will keep the occurrence of each value of our hand and after we have all the values we just iterate this array and multiply all the values by itself and adding them to get a unique result.
For example if we have [2,2,3,4,5] our fixed array will have a "2" and three "1" so our result will be "2*2+1*1+1*1+1*1",the result will be 7, so all the possible hands will have unique values, if we find a 7 as a result we will know it is a pair, a 9 will be two pairs, a 11 will be three of a kind, 13 will be a full house and 17 will be a four of a kind.
This algorithm is O(1) both in complexity and space but the interviewer didn't like it too much.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 1of 1 vote
AnswersGiven the two objects below, implement the methods defined in the Phonebook class. This is a simulated phonebook. You should expect LookupByName and LookupByPhoneNumber to be called much more often than AddPerson. Also, this is a multi-threaded simulation so your implementations of the functions other than the constructor should be threadsafe. Feel free to rewrite this in any language of your
choice.
- Surya November 10, 2015 in United States for Cloud servicespublic struct Person { string name; string phoneNumber; } public class Phonebook { public Phonebook (List<Person> people) { } public Person LookupByName(string name) { } public person LookupByphoneNumber(string phoneNumber) { } public void Addperson(person person) { } }
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Threads - 2of 2 votes
Answersthere are N cities (numbered from 1 to N) in the game and connect them by N-1 highways. It is guaranteed that each pair of cities are connected by the highways directly or indirectly.The game has a very important value called Total Highway Distance (THD) which is the total distances of all pairs of cities. Suppose there are 3 cities and 2 highways. The highway between City 1 and City 2 is 200 miles and the highway between City 2 and City 3 is 300 miles. So the THD is 1000(200 + 500 + 300) miles because the distances between City 1 and City 2, City 1 and City 3, City 2 and City 3 are 200 miles, 500 miles and 300 miles respectively.
- hulei660066 October 06, 2015 in United States for bing
During the game the length of some highways may change. you want to know the latest THD.
sample input
3 5
1 2 2
2 3 3
QUERY
EDIT 1 2 4
QUERY
EDIT 2 3 2
QUERY
sample output
10
14
12| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 4of 4 votes
AnswersWrite a program to process the matrix. If an element is 0 at ith row and jth column, then make the whole ith row and jth column to 0.
- codealtecdown September 17, 2015 in United States
Constraints:
Space complexity should be O(1)
Time complexity - Only single pass is allowed. Note that single pass is not O(n). This is single pass : An element will read and written only ones.
Edit:
Recursion is not allowed since it is O(n) space on stack| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 2of 2 votes
Answers
- chaos August 13, 2015 in United States for WindowsJohn observers the following while driving to work. • 4 were driving a red car. • 3 were driving a blue car. • 3 were driving a black car. He also notices that • 3 of them were listining to Hip Hop • 4 of them were listining to pop music. • 3 of them were listining to Rock. Additionally he notices that, • 3 of them reached office before time on Friday. • 3 of them reached office before time on Tuesday. • 2 of them reached office before time on Wednesday. • 2 of them reached office before time on Thursday. Which of the following practice maximises his chance of getting to office before time. a) He should drive a red car to work listining to pop music on a friday? b) He should drive a blue car to work listining to rock music on a Tuesday. State how did you calculate the probabiltiy for both in your answer.
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Brain Teasers - 3of 5 votes
AnswersGenerate all possible sorted arrays from alternate elements of two given sorted arrays.
- vishgupta92 July 28, 2015 in United States
Given two sorted arrays A and B, generate all possible arrays such that once first element is taken from A then from B then from A and so on in increasing order till the arrays exhausted. Then first element is taken from B then From A, and do same as above.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - -1of 3 votes
AnswersDesign a game like angry birds
- sg July 22, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - -1of 1 vote
AnswerCheck if the given cordinates on a map correspond to the correct address (where address or cordinates are provided in a tab separated file)
- sg July 22, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 1of 1 vote
AnswersReverse string except spaces. A string has mix of alphabets and spaces. Your task is to reverse the string, but preserve the positions of spaces. For example, reverse of " a if" is " f ia".
- sg July 22, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm