Last time I was interviewed for a software development engineer position, the recruiter asked me some of the classicalMicrosoft interview questions, such as “How Would You Move Mount Fuji?” or “How many gas station are there in your country?“.

It was the first time for me to be asked such questions but having obtained the job I think my answers were good enough.

After that day, I looked for other well-known interview questions
and I discovered that Google has a totally different approach, focusing
on algorithms, data structures and complexity.

For instance, one of Google interview questions says:

There is an array A[N] of N integers. You have to
compose an array Output[N+1] such that Output[i] will be equal to the
product of all the elements of A[] except A[i].

Example:
INPUT:[4, 3, 2, 1, 2]
OUTPUT:[12, 16, 24, 48, 24]

Solve it without division operator and in O(n).

Without the two constraints at the end of the puzzle it would have been straightforward, but now we have to be smart.

Actually, the product of all elements of A[] except A[i] is equal to the product of all elements before A[i] and those after A[i].

We can traverse A[] twice, once from left to right and once in the opposite way and multiply all the elements we find before A[i].

We’ll pretend to have a new array called Output[] to store the output of the first pass, assigning Output[i] the product of all elements preceding A[i]:

[...] fsharp.it posted the above simple Google interview question on their site a few weeks ago and subsequently the problem was referenced by OJ’s rants and later posted to the programming subreddit on reddit.com. Like everyone else, I sat down and wrote some quick code to solve the problem. After looking a the solution, it seemed to me that this was a rather poorly conceived problem- if not contrived at heart. It doen’t ring to the tune of scalability, performance and quality that one thinks of when the word Google is thrown into the mix. [...]

Lincoln
on
11/3/2008 12:06 AM
Hi Pavel,we should check how the concatenation operator @ is implemented, I’m not sure its complexity is O(n).BTW, your solution is very good!

aggie
on
11/3/2008 9:18 AM
[...] post was inspired by a recent interview question that was posted over at fsharp.it. It’s one of those neat little questions which looks really simple on the surface but is [...]

Aaron
on
11/3/2008 11:36 AM
I’m glad to hear that, in my opinion a good mix of problem solving and coding questions is the best way to interview people for software development positions.

John
on
11/3/2008 1:54 PM
Microsoft focus on the same thing, they have problem solving and coding questions. But they start with the logical ones on phone interviews.