XOR Swap - Stack Overflow for Tech Interview Questions
xorswap.com
xorswap.com
Based on my experience, A lot of tech interviews in large companies nowadays are mostly done by young people who have limited understanding of what a good employee is (because more tech savvy guys don't want to waste time with interviews) and who therefore keep asking rote questions like: "how do you shuffle a deck of cards", or (my favorite) "What is the 'mutable' keyword do?" and string matching the answer to the right one in their minds. This in turn has affected the interview preparation process, consisting mostly of memorizing the answers to the rote questions.
Which (as the architect in The Matrix said) has led the would-be coders, inexorably, here and similar sites.
more tech savvy guys don't want to waste time with interviews
Piaw Na wrote a great explanation of how Google gets this wrong last year. Choice quotes:"I had all sorts of perverse incentives to not interview people."
"If you wanted to get promoted for these non-engineering tasks, move into management."
The HN thread was exellent as well with 135 comments: http://news.ycombinator.com/item?id=1865099
I dunno -- if there's a giant, fairly-comprehensive question bank, and you can quickly reproduce from memory a good answer to each question, isn't it just possible you've actually learned the material?
Do people actually ask this. I can't understand if it should be, "What the the mutable keyboard 'do'". I'm not sure of any mutable keywords by the name of "do". Or did you mean "What does the 'mutable' keyword do". Again, I'm not familiar with any popular programming languages with the keyword mutable. If they are just asking for the definition of mutability, that seems a strange question for a technical interview.
From my experience most of these interviews at these big tech companies have these kind of questions. And they suffer from having inexperienced engineers conducting the interviews. I think this is a big, untalked about problem with regard to why tech companies have such a lack of talent.
See for example http://stackoverflow.com/questions/105014/c-mutable-keyword
It is interesting, sometimes when you consider two different syntactic forms of a sentence, the written form has vestiges from both.
"if you read our exam dumps Seriously, you will pass the exam 100%"
vs
"candidates will be able to leap through the common hurdles of technical interviews"
These sites do neither candidates nor interviewers any favours.
I didn't go searching for questions so I could recite the answer during the interview, but instead to instead give myself a mental warmup. It's akin to sports people stretching before they run a race.
Whether the questions themselves are indicative of strong future performance is another question entirely, but at the very least I do enjoy the majority of Google's interview questions. Analytical and algorithmic puzzles are entertaining and I think it's those sorts of people that Google are filtering for.
http://sportsmedicine.about.com/cs/flexibility/a/aa022102a.h...
Soccer, basketball, dancing, weight lifting, rock climbing, none of these have anything to do with those results, and you should talk to people who have been doing the activity for years about how to be healthy, not about.com.
The studies do agree in general, however, that stretching before exercise does NOT reduce the chance of injury.
Some scientific articles this time: http://scholar.google.com/scholar?q=stretching+injuries+stud...
Then, perhaps with strong moderation, only questions that demand some compromises should be accepted. e.g. implement a container that can be traversed both forwards and backwards. What are the complexities of your container? How could you improve X, and what would the cost be? etc.
One of the questions is 'Design a Twitter-like social network web application'. This is obviously not a small or quick project. I'm guessing Google asks this in the hopes of getting a hand-wavy answer and analyzing you based on that. I'm not saying your idea shouldn't happen (it would make an interesting site) but I don't know that it would work for all the questions.
Edit: oh, even worse, it tags them by the company that asks the question. Great. I'm sure those companies will appreciate having to come up with brand new questions for each candidate. And candidates will really be better off getting in based on memorized answers, then finding themselves unable to solve the actual problems in the job. (sarcasm)
So you might as well test how well people can Google rather than solving a problem by themselves... :-)
The only question I would ever ask about the XOR Swap trick would probably be "Give 3 reasons never to use this" (assuming you are in a language as least as high level as C).
1) It obfuscates (the most obvious thing, but still worth mentioning).
1) It is incorrect if you swap a memory location with itself (which many algorithms, like sorts, can end up doing without meaning to).
2) It is always slower on any modern optimising compiler than using a temporary in Java, C and C++ (a strong claim to make, but I stand by it. That's why I list specific languages where I know about the internals). Modern compilers use "flow" techniques for temporary variables. A swap will usually compile away to the compiler internally relabelling which value is in which register, and therefore no code at all.
Better questions work something like this: what's the most challenging technical problem you had to solve in your last job? Why was it so challenging? What did you have to learn to solve it?
Of course, depending on the application computer science "trivia" could actually be part of the job requirement. E.g. if you're trying to build a scalable web service, maybe it really is important for the candidate to know when to use a heap.
I think a more or less unequivocally bad interview question is how to figure out if a linked list ever loops back using constant space. Maybe I'm just extrapolating my own stupidity, but I don't think that's the sort of thing people can reliably be expected to discover for themselves on the fly, so you'll just end up filtering out folks who haven't heard the answer to the question already.
Case in point: http://xorswap.com/questions/85-what-is-a-hash-table-how-wou...
No offense to ankur, but his hash function is the silliest hash function ever. It looks intelligent and reasonable and is the kind of answer I would trust if I didn't know better. But what kind of hash function is injective? If I wanted to store arbitrary doubles into his hash table I would need a zettabyte (that is a billion terabytes) of memory. Ooops. I should be able to warn people about that somehow.