views:

278

answers:

4

Hi all.

So I just finished an interview with a major software company for an internship (I am an undergrad). I had some weird experiences during the interview, so I thought I had share them here and ask for feedback.

I was interviewed on-campus so there was no telephonic round.

Before the interview began, we were given a choice of a programming language. I picked C++. The interview began and the first question I was asked was about reversing a string (after the interview I came to know what a common question that was).

Now of course, I have always been told not to reinvent the wheel since time immemorial. So of course, being taught that by mentors, I did:

std::string s = "This is a string."; 
std::reverse(s.begin(), s.end()); 
std::cout << s; 

The interviewer was not impressed. There was an immediate frown on his face. He then told me, 'Do this without using the standard library.'

Now my question is, what does one do? For example, I have always used std::sort without bothering about its internals. To actually understand how it works, one has to implement it. But if I ever did that, I was told to stop reinventing the wheel.

My question is, how does one handle such situations in an interview? For someone like me who uses the standard library without knowing anything about its internals, how do I handle interview questions such as these, where we are asked to reinvent the wheel? And being an undergrad, I can't possibly be expected to know the inner details of a standard library.

This is just one example. Indeed the string reversing example is easy to implement, but what about other situations? How have you handled them? Or to be a good programmer, I should be knowing the inner details?

PS: I was not selected.

+16  A: 

The point of the question isn't to reinvent the wheel - it's to see whether you could invent it in the first place, and do so efficiently.

The way you should handle such situations is to understand the context of the question: you're not being asked to do this as part of "real work", you're being asked to do it in an attempt to assess your cognitive abilities. So you do it as well as you can, explain your reasoning, etc.

The questions I typically ask in interviews are similar - you'd never want to write that code in real life, but typically the code you do write in real life doesn't make a good interview question; there's far too much context (and frankly far too little genuinely interesting and difficult code) to fit into 45 minutes. Instead, you pick a "toy" example which allows you to examine various aspects of a candidate's ability: design, actual coding, algorithmic complexity, communication skills, adaptability, attention to detail etc.

Jon Skeet
Thanks for the advice. I will keep this in my mind for my next interview.
sukhbir
@PulpFiction - it's likely that 99% of sort, string reversal and tree traversing code is written in interviews. Nobody ever needs to write this in real life. Ironically of course they are better hiring a programmer that nows string::Sort than one who will write their own string reverser for production code!
Martin Beckett
+3  A: 

It's not a question of inner details.

Ask yourself what the interviewer is trying to establish. In this case, they wanted to know if you could formulate the algorithm to take a char off the end of a string and add it to a new one, so you could spell it out and then mention the library.

It's not a memory game, they wanted to know how you attack a problem and how you think.

SteveCav
So in such cases, first I should do it the old fashioned way and then tell him the std library way of doing it?
sukhbir
+2  A: 

Well it is common for people to ask such questions in interviews be it for an intern or a full job posting.

The fundamental thing is to attempt to solve the problem. Like having a verbal discussion or overview on various ways to approach the problem to find a solution.

For example for the string reversal question, what the interviewer would be looking for is an algorithm or mechanism to find out the end of the string and then reverse contents.

He may not look for a fully compilable program that will handle all cases. The intention of finding the solution is what interests the interviewers.

Interviewers check for basic things like

  1. Your logic
  2. COnfidence

  3. Interaction and justification

  4. Problem solving kills

For entry level people the interviews would look for how you tackle the problem and how you arrive at the logic.

Moving further down for experienced guys more stress would be given on efficient implementation, reuse etc...

PS: Bottomline is attempt to solve and justify your reasons in favour of the solution

ckv
I like number 4. - problem solving kills... hahaha
Ido
Aah I get it. I never knew much about interviewing, this being my first.
sukhbir
Well i hope you have got some idea now atleast.
ckv
If you can explain more on what else was asked and how the general interview went we can help you more
ckv
@ckv: Thanks, the rest of the questions were on linked lists, which I never knew were such an important topic! And then general questions on operating systems. I think I was left out cause on more than one occasion I did what was the obvious method of doing it.
sukhbir
May i know the reason for the downvote?
ckv
I didn't do it :) Thanks for your answers.
sukhbir
A: 

A good response is that good engineering uses proven techniques rather than trying to do something new and clever every time.

The interviewer may well agree and ask you to re-invent the wheel anyway.

dwarFish