Microsoft Interview Questions
- -1of 1 vote
AnswersGiven a circular array of images, in LandScape and Portrait mode. Bidirectional movement in array is allowed.
- rajnikant12345 March 13, 2016 in India for Office
e.g.
LPPPLPPP
L-> Landscape
P-> Portrait
Cost of Viewing a Portrait image is Vp
Cost of Viewing a Landscape is (Rp(rotate) + Vp).
Cost of movement is -> m
once you visited the image viewing cost is zero if you revisit the image. Only movement cost is considered.
Jumps in array is not allowed.
Calculate the maximum number of images you can see with cost X.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 3of 3 votes
AnswersGiven a string e.g. ABCDAABCD. Shuffle he string so that no two smilar letters together.
- rajnikant12345 March 13, 2016 in India for Office
E.g. AABC can be shuffled as ABAC.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 String Manipulation - 0of 0 votes
AnswersGiven a DNA sequence e.g. AAAGTAAGTAAGTGGG.....
- rajnikant12345 March 13, 2016 in India for Office
Find all the duplicates with length 10.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 String Manipulation - 1of 1 vote
Answerswhat is the best sorting algorithm in terms of complexity and why?
- Rajesh Burla March 11, 2016 in India| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Algorithm - 0of 0 votes
AnswersCircular Queue - what it is ? and write a program for this
- its3707 February 18, 2016 in India| Report Duplicate | Flag | PURGE
Microsoft SDET Algorithm - 0of 0 votes
AnswersCircular Queue - what it is ? and write a program for this
- its3707 February 18, 2016 in India| Report Duplicate | Flag | PURGE
Microsoft SDET Algorithm - -2of 2 votes
AnswersI have an array of integer. That provides data to one of the UI screen. That UI screen can show at a time only one data. For each iteration on the array 3 elements get picked up however only the highest number out of those usually shows up on the UI.
- its3707 February 18, 2016 in India
{1,4,5,2,3,4,5,6} means if 1,4,5 picked up only 5 will be shown up on the UI
in next iteration 4,5,2, should be picked up.
next iteration 5,2,3
write a solution for this.| Report Duplicate | Flag | PURGE
Microsoft SDET Algorithm - -2of 2 votes
AnswersI have an array of integer. That provides data to one of the UI screen. That UI screen can show at a time only one data. For each iteration on the array 3 elements get picked up however only the highest number out of those usually shows up on the UI.
- its3707 February 18, 2016 in India
{1,4,5,2,3,4,5,6} means if 1,4,5 picked up only 5 will be shown up on the UI
in next iteration 4,5,2, should be picked up.
next iteration 5,2,3
write a solution for this.| Report Duplicate | Flag | PURGE
Microsoft SDET Algorithm - 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 - 0of 0 votes
AnswersGeneric Question: You have a list of items that's nearly sorted. What algorithm would you use to completely sort it? Even though it's already sorted, the least element could be at the other end ...eg: 4,5,6,7,8,9,10,11,1
- Engineer1111 January 24, 2016 in United States
She then said that what would be the approach if the data was not like that, as in , not so extreme.| Report Duplicate | Flag | PURGE
Microsoft Dev Lead Algorithm - 0of 0 votes
AnswersGiven a string that represents an integer with no upper bound (billions, trillions, etc..), write a function "convert" that returns the integer value of the string. For example: "1000322" returns 1000322.Try to do this in O(1) space, and O(n) time. Better if possible.
- william.brandon.lee83 January 18, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-3 Algorithm - 0of 0 votes
AnswersGiven a binary tree, write a function LCA that returns the least common ancestor of two nodes. This is not a BST. Try not to use parent pointers in the custom Node class.
- william.brandon.lee83 January 18, 2016 in United States
Iterative solution takes O(1) space, recursive solution takes O(n) space.| Report Duplicate | Flag | PURGE
Microsoft SDE-3 - 0of 0 votes
AnswersGiven a list of IP address correspondences, such as
- william.brandon.lee83 January 18, 2016 in United States
IP1 = IP2
IP3 = IP4
IP3 = IP2
IP5 = IP6
IP7 = IP8
etc.
Return a list of unique IP addresses. In this case
IP1, IP5, IP7
Consider IPs as Strings or any other data type.| Report Duplicate | Flag | PURGE
Microsoft SDE-3 Algorithm - 0of 0 votes
AnswersGiven a list of integers (array or list), write a function that returns true if the list can be split into two lists that have an equal sum.
- william.brandon.lee83 January 18, 2016 in United States
Example: {4,2,2,0,-1, 1} returns true
{4}, {2,2,0,-1,1}
and {3,3,1} returns false.
Hints by interviewer:
- Complexity is 2^n| Report Duplicate | Flag | PURGE
Microsoft SDE-3 Algorithm - 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 a 2d array (say n*m), visit all elements faster than linear time (i.e. faster than m*n). (Assume not too big array. i.e. fits in memory etc.etc)
- AnonymousN December 08, 2015 in United States
I gave a solution: 4 pointers that start from 4 ends ((0,0), (0,n), (m,0), (m,n)) and walk the edges. Once done next inner rows and columns (i.e. (1,1), (1,n-1), (m-1,1), (m-1,n-1)). Easier to implement with just the indices and we can say 4 times faster. Another solution I gave was to use multithreading. He said no multithreading. But the interviewer was not convinced and he gave me a hint to use recursion (?). Couldn't get the solution that he wanted.| Report Duplicate | Flag | PURGE
Microsoft Site Reliability Engineer - -1of 3 votes
AnswersA frog has to cross the river from one end to another end. river has stones in between randomly where frog can jump. frog can't jump into the river. problem is that will frog ever reach other end with following conditions?
- anuprao85 December 01, 2015 in United States for Office
1. frog allow to do same jump as previous jump. or
2. frog allow to jump 1 more as previous jump. or
3. frog allow to jump 1 less as previous jump.
consider river as Boolean Array. Stone is a element in array where value is true .| Report Duplicate | Flag | PURGE
Microsoft Software Developer Data Structures - 3of 3 votes
AnswersGiven a singly connected linked list, find the largest palindrome in the list in O(1) space.
- neer.1304 November 29, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 3of 3 votes
AnswersGiven a linked list consisting of String in each Node . Given just a pointer to the head Node find whether the resultant String formed by combining all the Nodes of the linked list is a palindrome or not in O(1) space and O(n) time.
- neer.1304 November 29, 2015 in United States
eg – Consider this linked List structure
“aba” -> “cd” -> “efe” -> “d” -> “caba”
Hence this structure is palindrome .| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
Answers2 process runs the following code. What will be the output
// Assume this address is legal address for both the process int *sharedmemoryaddress = 0x1232; void SomeRunningFunction() { for(int i = 1; i < 1000; ++i) { *sharedmemoryaddress = i; sleep(2000); } }
What does the 2 process print. Consider unicore and multicore processors. What is the significance of sleep here. What are we achieving from sleep.
- rishab99999 November 29, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft - -1of 1 vote
AnswerGiven an N-ary tree with thousands of nodes in it. Pair (Join) the Leaf nodes which do NOT SHARE the common path. i.e. Two Leaves can be Paired only if they do NOT have Intersecting path.
- neer.1304 November 28, 2015 in United States
For example,
A
/ | \
B C D
/ / | \
E F G H
Leaf nodes: E, F, G, H & D
Possible Pairs in O/Ps:
a) (E-F), (G-H) or
b) (E-G), (F-H) or
c) (E-H), (F-G) or
d) (E-D), (F-G) or
e) (E-D), (G-H) or
f) (E-D), (F-H) or
g) (D-H), (F-G) or
h) (D-G), (F-H) or
i) (D-F), (G-H)
Note: If we pair(join) say, (E-F) then we can NOT pair any of the (D-G) or (D-H) as they SHARE the COMMON path from A to C.
i.e. E-B-A-C-F —> (E-F) pair
D-A-C-G —> (D-G) pair
D-A-C-H —> (D-H) pair| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven a tree, and a pointer to some node in the tree, print the left most element in the same level as that node
- neer.1304 November 28, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven an input of the calendar objects of 10,000 employees, input is a time interval T and an employee[] array, find the first interval where all the employees in the employee[] array are free for a minimum time interval T (i.e schedule the meeting)
- neer.1304 November 28, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm