Author: Svetlin Nakov
March 15, 2008
Last month I was invited by Microsoft to an interview in their largest european development center in Dublin. It was exciting trip and real challenge to see the Microsoft development live. I was excited of their professionalism in all directions:
- Professional organization – phone interviews, invitation, flight, accomodation, etc.
- Nearly perfect development process – like I read in the software engineering books
- Very skillful developers and managers that interview me
- Really professional way of conducting interviews
- Challengeable product development
I was most excited on the people and the development process. I think this is what makes Microsoft so successfull: brilliant people and solid engineering process.
Microsoft made a small negligence: they didn’t ask me to sign any NDA agreement, so I can share all the interview questions to help all other candidates who want to join Microsoft.
Interview Questions @ Microsoft Dublin
I had 5 interviewers asking me lots of software engineering questions. The questions were very adequate for the team leader position that was my objective (“program manager” position in Microsoft is a senior technical position, like a team leader in a typical software development company). Interviewers were not just asking me to explain some technical concept or propose a solution to some real-world problem. They gave me a blackboard to write some code in order to see how I am attacking the problems, what types of pictures I draw, how exactly my thinking flows, etc.
I remembered most of the interview questions and the answers I gave. I hope my answers were good because I was approved and the recruiter from Microsoft sent me a job offer few days after the interview. Below are the questions with my answers:
Interview Question 1: You need to architecture the security for a bank software. What shall you do?
There is no exact answer here. This question is about thinking: follow the existing standards in the banking sectors, establish global security policy, secure the network infrastructure, secure the application servers, secure the databases, establish auditing policy, securing the operators’ workstations, secure the Internet and mobile banking portal, etc. Think about authentication (smart cards), authorization, secure protocols, etc.
Interview Question 2: You are given a string. You want to reverse the words inside it. Example “this is a string” –> “string a is this”. Design an algorithm and implement it. You are not allowed to use String.Split(). After you are done with the code, test it. What will you test? What tests will you write?
I knew an elegant solution in 2 steps:
1) Reverse whole the string char by char.
2) Reverse again the characters in each word.
You need to write a method Reverse(string str, int startPos, int endPos).
To test this method test normal cases first (middle of the word, beginning of the word, end of the word, 1 character only, all leters in the string). Check bounds (e.g. invalid ranges). Test it with Unicode symbols (consisting of several chars). Perform stress test (e.g. 50 MB string).
Write a method ReverseWords(string s). Test it with usual cases (few words with single space between), with a single word, with an empty string, with words with several separators between. Test it with string containing words with capital letters.
Interview Question 3: What is the difference between black box and white box testing?
Black box testing is testing without seeing the code. Just looking for incorrect behaviour.
White box testing is about inspecting the code and guessing what can go wrong with it. Look inside arrays (border problems), loops (off by 1 problems), pointers, memory management (allocate / free memory), etc.
Interview Question 4: What is cross-site scripting (XSS)?
Interview Question 5: What is SQL injection?
SQL injection is vulnerability comming from dynamic SQL command text created by concatenating strings with an input comming from the user, e.g. string cmd = “SELECT * from USERS where LOGIN='” + login + “‘ and PASS='” + password + “‘”. if username has value “‘ OR 1=1 ‘;”, any login / password will work. To avoid SQL injection use parameterized commands or at least SQL escaping.
Interview Question 6: What is the most challengeable issue with multithreading?
Maybe this is the synchronization and avoiding deadlocks.
Interview Question 7: Explain about deadlocks. How to avoid them?
Deadlock arise when 2 or more resources wait for each other. To avoid it, be careful. Allocate resources always in the same order.
Interview Question 8: Do you know some classical synchronization problem?
The most important classical problem is “producer-consumer“. You have several producers and several consumers. Producers produce some kinf of production from time to time and consumer consume the production from time to time. We have limited buffer for the production. When the buffer is full, producers wait until space is freed. When the buffer is empty, the consumers wait until some producers put something inside.
Practical use of the producer-consumer pattern is sending 1 000 000 emails (production) with 25 working threads (consumers).
Interview Question 9: You need to design a large distributed system with Web and mobile front-end. Through the Web customers subscribe for stock quotes (choosing a ticker and time interval) and get notified by SMS at their mobile phones about the price for given tickers and the requested intervals. A web service for getting the price for given ticker is considered already existing.
Use 3-tier architecture (ASP.NET, C# business tier, SQL Server database). Use a queue of tasks in the business tier and a pool of working threads (e.g. 100 threads) that execute the tasks. A task has 2 steps (query for the ticker price and send SMS). These steps are executed synchronously (with reasonable timeout).
We have another thread that performs SQL query in the database to get the subscriptions matching the current time and appending tasks for SMS notification.
We consider the SMS gateway is an external system.
Interview Question 10: How you secure the stock quote notification system?
We need to secure all its parts:
1) The user registration process – need to verify phone number with confirmation code sent by SMS. Need to keep the password with salted hash. Need to keep the communication through HTTPs / SSL.
2) The application server with business logic. Secure the host, put reasonable limitations to avoid flooding the server.
3) Secure the database (e.g. Windows authentication without using passwords).
4) Secure the network (e.g. use IPSEC)
5) Secure the access to the Web service (WS Security).
6) Secure the mobile phone (e.g. sending encrypted SMS messages and decrypt them with a proprietary software running on the phone).
Interview Question 11: How you write a distributed Web crawler (Web spider)? Think about Windows Live Search which crawls the Internet every day.
You have a queue of URLs to be processed and asynchronous sockets that process the URLs in the queue. Each processing has several states and you describe them in a state machine. Using threads with blocking sockets will not scale. You can still use multiple threads if you have multiple CPUs. The Web crawler should be stateleass and keep its state in the DB. This will allow good scalability.
A big problem is how to distribute the database. It is very, very large database. The key here is to use partitioning, e.g. by site domain. Take the site domain, compute a hash code and distribute the data between the DB nodes based on the hash code. No database server can store all the pages in Internet, so you should use thousands of DB servers and partitioning.
Interview Question 12: You have a set of pairs of characters that gives a partial ordering between the characters. Each pair (a, b) means that a should be before b. Write a program that displays a sequence of characters that keeps the partial ordering (topological sorting).
We have 2 algorithms:
1) Calculate the number of the direct predecessors for each character. Find a character with no predecessors, print it and remove it. Removing reduces the number of predecessors for all its children. Repeat until all characters are printed. If you find a situation where every character has at least 1 predecessor, this means a loop inside the graph (print “no solution”). Use Dictionary<string, int> for keeping the number of predecessors for each character. Use a Dictionary<string, List<char>> to keep the children for each character. Use PriorityQueue<char, int> to keep the characters by usign their number of predecessors as priority. The running time will be O(max(N*log N, M)) where N is the number of characters and M is the number of pairs.
2) Create a graph from the pairs. Use recursive DFS traversal starting from a random vertice and print the vertices when returning from the recursion. Repeat the above until finished. The topological sorting will be printed in reversed order. The running time is O(N + M).
Interview Question 13: You are given a coconut. You have large building (n floors). If you throw the coconut from the first floor, it can be broken or not. If not you can throw it from the second floor. With n attempts you can find the maximal floor keeping the coconut intact.
Now you have 2 coconuts. How many attempts you will need to find the maximal floor?
It is a puzzle-like problem. You can use the first coconut and throw it from floors: sqrt(n), 2*sqrt(n), …, sqrt(n) * sqrt(n). This will take sqrt(n) attempts. After that you will have an interval of sqrt(n) floors that can be attempted sequentially with the second coconut. It takes totally 2*sqrt(n) attempts.
Interview Question 14: You have 1000 campaigns for advertisements. For each of them you have the returns of investments for every day in a fixed period of time in the past (e.g. 1 year). The goal is to visualize all the campaigns in a single graphics or different UI form so the user can easily see which campaigns are most effective.
If you visualize only one campaign, you can use a classical bar-chart or pie-chart to show the efficiency at weekly or monthly basis. If you visualize all campaigns for a fixed date, week or month, you can also use classical bar-chart or pie-chart. The problem is how to combine the above.
One solution is to use a bar for each campaign and use different colors for each week in each bar. For example the first week is black, followed by the second week, which is 90% black, followed by the third week which is 80% black, etc. Finally we will have a sequence of bars and the most dark bars will shows best campaigns while the most bright bars will show the worst campaings.
I knew that I was approved even at the interview. It was a good sign that the manager of the development in Microsoft Dublin for the Windows Live platform Dan Teodosiu personally invited me in his office at the end of the interview day to give me few additional questions and to present me the projects in his department. Dan is extremely smart person – PhD from Stanford University, technical director and co-owner of a company acquired by Microsoft few years ago. It was really pleasure for me to meet him.
There were 2 teams in Dublin that wanted to have me onboard: the edge computing team working on Windows Live and the Office Tube team working on video recording and sharing functionality for the Microsoft Office. I met the manager of the Office Tube team at the end of the interview day to discuss their products and development process.
I was Offered a Senior Position @ Microsoft Dublin
Few days later I was offered a senior software engineering position at Microsoft in Dublin. I was approved and the recruiters started to talk with me about my relocation in Dublin. Few days later I received the official offer from Microsoft. It was good enough for the average Dublin citizen but not good enough for me.
I Rejected Working at Microsoft Dublin
Yes, I rejected the Microsoft’s offer to work in their development center in Dublin. The reason was that their offer was not good enough. The offer was better than the average for the IT industry in Dublin. It was good offer for a software engineer and if I got it 5-6 years ago I would probably accept it.
I was working as software engineer for more than 12 years. I am currently CTO and co-owner of a small software development, training and consulting company and I am a team leader of 3 software projects in the same time (two Java and one .NET project). In the same time I am a head of the training activities and I manage directly more than 10 engineers and of course I am paid several times better than the average for the industry. In the same time I am part-time professor in Sofia University. I am about to finish my PhD in computational linguistics. I have share in few other software companies. All of this was a result of many years of hard working @ 12+ hours / day.
In Bulgaria I was famous, very well paid, working at own company with no boss, managing development teams and having very good perspective for development. To leave my current position, I needed really amazingly good offer. I got good offer, but not amazingly good. That’s why I rejected it.
My Experience at Interviews with Microsoft and Google
Few months ago I was interviewed for a software engineer in Google Zurich. If I need to compare Microsoft and Google, I should tell it in short: Google sux! Here are my reasons for this:
1) Google interview were not professional. It was like Olympiad in Informatics. Google asked me only about algorithms and data structures, nothing about software technologies and software engineering. It was obvious that they do not care that I had 12 years software engineering experience. They just ignored this. The only thing Google wants to know about their candidates are their algorithms and analytical thinking skills. Nothing about technology, nothing about engineering.
2) Google employ everybody as junior developer, ignoring the existing experience. It is nice to work in Google if it is your first job, really nice, but if you have 12 years of experience with lots of languages, technologies and platforms, at lots of senior positions, you should expect higher position in Google, right?
3) Microsoft have really good interview process. People working in Microsoft are really very smart and skillful. Their process is far ahead of Google. Their quality of development is far ahead of Google. Their management is ahead of Google and their recruitment is ahead of Google.
Microsoft Seems Like a Better Place to Work than Google
At my interviews I was asking my interviewers in both Microsoft and Google a lot about the development process, engineering and technologies. I was asking also my colleagues working in these companies. I found for myself that Microsoft is better organized, managed and structured. Microsoft do software development in more professional way than Google. Their engineers are better. Their development process is better. Their products are better. Their technologies are better. Their interviews are better. Google was like a kindergarten – young and not experienced enough people, an office full of fun and entertainment, interviews typical for junior people and lack of traditions in development of high quality software products.
Tags: black box testing, brilliant people, career, classical synchronization problem, cross-site scripting, deadlocks, development process, distributed Web crawler, Google interview, Interview, interview at microsoft, interview process, interview questions, interview questions Microsoft, it interview, job interview, job offer, large distributed system, Microsoft, Microsoft Dublin, microsoft interview, microsoft interview questions, multithreading, partial ordering pairs, producer-consumer problem, program manager at Microsoft, puzzle-like problem, reverse the words in a string, secure a stock quote notification system, security for a bank software, senior position at Microsoft Dublin, senior software engineering position, SMS gateway, software development, software engineering, software engineering questions, solid engineering process, SQL injection, top-post, topological sorting, two falling coconuts, UI for advertisements campaigns, white box testing, XSS