The Worst Programming Interview Question
nomachetejuggling.com
nomachetejuggling.com
Obviously it depends on the job I was interviewing for. Let's assume I'm not angling for a position as lead on a distributed load balancing layer or something.
I suppose if they're looking to see my problem solving workflow then I'd look like kindof a dick. But then, as the article points out, so would they.
Point being, you're demonstrating initiative and, that old cliche, thinking outside the box. Think Will Smith in Men In Black.
Some interviewers might be impressed with your lateral thinking, others might be annoyed at your attempt to be a 'smart ass' and avoid the intention of the question. But that's always the problem with these type of interview questions, it depends so much on the expectations of the interviewer.
Maybe this points to a better class of interview questions: the interviewer supplies the broken algorithm, the interviewee supplies the bugfix.
I think that applies to junior positions, too.
It felt that they were interviewing for a computer scientist despite advertising for a software engineer.
Needless to say, we were mutually not a good fit.
But if you go up a few steps then suddenly the problems might not be that clearly defined and the set of possible solutions can be huge. A person who is constantly relying on Google to come up with solutions is probably not going to be that useful in design discussions.
I'm not defending the particular question, but on-your-feet problem solving is a real and valuable skill.
For example, given the loop in linked lists question, even if a candidate is not able to solve it completely, a reasonable approach would be to break the general case to more specific, trivial cases, such as: what if the loop has known length, what if the loop starts at a known location, etc. Interview questions are not binary decisions, you can learn a lot from a candidate just by seeing how they respond to a question.
But then in that case, the problem as given is still bad, because it gives that part away! If you want to test this ability, you shouldn't frame the problem in terms of linked lists. As another poster here suggested, you should ask something like "The customer gave a list of everyone and who they report to. How would you sanity check the hierarchy?"
That then requires the candidate to identify cycles as something they'd want to look for, and then this problem as a special case of "find a cycle in a linked list".
>> Obviously it depends on the job I was interviewing for.
In my experience, it often does not depend on the job. Interviewers ask such things even if the job does not require it because ... ultimately because they are not good interviewers. If you get asked the question, the best bet is to just answer it or else the interview goes downhill from that point on.
> People like to pose puzzlers to “see how people think” but that’s nonsense in the case of puzzler questions. You can’t reason your way through a puzzler, that’s why it’s a puzzler
There are plenty of ways to solve this problem. They're not all optimal, of course, but you don't ask these questions to get the optimal solution, you ask these questions to understand how the person reasons about them.
This more falls on the interviewer than the candidate. It's upon the interviewer to encourage a dialogue about the problem and talk aloud through it.
Yes, some qualified candidates are bad at this. I'm sorry to hear that, but it can be practiced. Being good at interviewing can be learned. It's not terribly difficult. My number one pro-tip? Never do this:
> If you don’t have the a-ha moment in the interview, you won’t get it, and a good chunk of your brain will be devoted to thinking “oh shit I’m blowing this interview” rather than focusing on the question at hand.
Never think that you're blowing the interview. I got a job at Google and I know for a fact that I didn't get the optimal solution to some of my questions. It's not about the solution, it's about the process.
http://www.nytimes.com/2013/06/20/business/in-head-hunting-b...
I was not asked silly questions like "how many golf balls could you fit in a school bus" or "how do you move a mountain 3 feet to the side". These are the types of questions he explicitly references in the article.
edit: I will also add that there are differences between eng and non-eng interviews. I'm not familiar with the non-eng process really.
But how many times did you ask this question without actually verifying that YOU could answer it? And what does that mean about your process for generating and grading interview questions? And why did it have to be the interviewee who told you?
Maybe interviewees should be more confident, but maybe interviewers should be a little less self-confident. This is a huge cultural problem for the industry, but it's right in our blind spot.
And we have to ask why there are less women in tech since it became dominated by erroneously self-confident, high-testosterone personalities who think that hiring people like themselves is a meritocracy?
How many times had I asked it? 50? I had a couple folks answer it like I thought it should be answered. He was the only who nailed it enough to catch the error too.
The reality is interview performance is very different than work performance. Interview questions test interviewing ability more than anything else.
Over time I've realized that the only reliable predictor of success is seeing people's work results first hand when they don't think they are interviewing. The danger is this too breeds issues of familiarity and lack of diversity, because one only hires from their narrow circle of the world.
This makes it very tough to make college hires. The only things I've seen that worked are "High enough" GPA (with "High enough" being higher on non-technical majors) and some sign that the student had to significantly multi-task (lots of extra curriculars, research, or working through school). Most 21 year olds don't have interview training, so it's a very bad way to pick them.
How do you that? Because that's all I ever think about once I mess up during interviews, and it's all downhill from there.
In practice, you may lose even if the interviewer is wrong. I have. At some big-name companies.
Just for example, an interviewer at Apple was adamant that frequency can never be negative. Whatever happens to Fourier transform that integrates frequency from negative infinity to positive infinity.
I have more examples. :-)
In every day life, this is not the thought process I go through if I make a mistake. But in an interview the stakes are higher, you'll be quickly discarded if you don't do well.
I have witnessed this. I was asked to write code for LRU cache [1]. I started out wrong, thinking that LRU caches "Least Recently Used" items (in other words, most recently used need to be discarded). It turns out that LRU cache "discards" LRU items. I wonder if the name is actually a misnomer.
I caught this extremely quickly though on the very first hint and then tried to confirm the definition multiple times, but the interviewer had mental blocks by that time, nodding his head without even listening to what I was asking.
Obviously if someone is lacking in confidence, is anxious or is a humble person, they should just learn not to be that person any more so they can get a Google job like you, the paragon of success.
Otherwise, they DESERVE to be judged as unqualified. That certainly follows.
Do you interview people to discover if they are good on the job, or just to discover if they are good at interviewing?
I've used an arguably "puzzle" question that was presented to me in an interview with some success -- the missionaries and cannibals problem. There are three missionaries and three cannibals that you must get across a river. The boat holds only you and one other person. The cannibals on either bank must never outnumber the missionaries on that bank. It's a good question to see if a candidate understands how to apply some basic computer science concepts. It can easily lead to a 30 minute discussion at the white board, with no need to get working code.
My favorite question is completely different. "What do you like best about your favorite programming language and what would you change about it if you could?" Anyone who doesn't see any flaws in their favorite language, particularly if it's Java, gets politely shown the door.
That is, the person who comes to realize the canonical way of solving it may truly be brilliant and having been hinted and helped along the way came up with the solution, or he might have already known it and just played a metagame, assuming that's what you wanted.
Basically, you have four possible outcomes:
People who have never heard of it, don't come up with the canonical solution.
People who have heard of it and just blurt out the answer.
People who have never heard of it, but who come to realize it over the course of the interview.
People who have heard of it and who play it as a game, working towards it and then suddenly having an epiphany.
The first is interesting. The second you hopefully dispense with the question as being useful. The third would be a great hire, but is indistinguishable from the fourth, who you've learned nothing about except they know how to play your interview process. Which may or may not be the criteria you're looking for.
"There are 128 chairs on a ski lift. You get on at the bottom, and ride it all the way to the top. On your trip up, how many do you pass on their way down?"
There may have been some distracting info of distances and speeds in there to make get you going in the wrong direction.
My experience with puzzlers is that average people like to feel superior for knowing the answers to a puzzle that someone else doesn't know. The people who can solve these easily are thrilled to find a puzzle they don't know the answer to. Then there is the group who can make a good puzzle.
Actually this is a simplification as the chairs slow down and bunch up at the bottom and top to make getting on and of simpler
Yeah, this is the problem with the question that I noticed as well.
If you don't know what a ski lift is (grew up in the south and didn't have money for vacations as a kid), you might not even know how ski lifts work. In which case maybe you guess that the chairs are fixed and give the 127 answer. Ironically, you guessed wrong and got the correct answer.
If you do know how ski lifts work and assume the interview does as well, then you just look like an idiot.
I guess the lesson is to state all your assumptions (and also, don't ask these questions).
Or, at least, I think it does. I'd love to have data on which interview questions actually elicit signal-containing answers...
What about the poor people who've found a language that they actually like, and understand the tradeoffs that were made? I suspect I recently failed an interview for not having a good answer to that question, but really, what am I supposed to say? If I thought there were significant problems with my favourite language, I'd find a better one.
Having said that, it does surprise me that people have a hard time with this. Certainly I hope that you like your chosen language and understand the tradeoffs being made, but that is the point of the question really. Surely you can reason about these tradeoffs and have a discussion in this area? If your language is Java and you talk about how you are ok with their decision on erasure because of the legacy concerns, that's a good answer. I may (or may not) agree, but it's still a perfectly good answer. :)
OTOH, it is strange to me that someone would have worked in a language for 10+ years and literally can't come up with anything that they dislike (even understanding the reasons for those limitations). No matter how good something is, it is hard to imagine working with anything (or anyone) for ten years without coming up with a few pain points.
I wouldn't feel comfortable answering "what would you change about X" with something I actually wouldn't change about X (though maybe I should).
(FWIW my language was Scala, and while I've only been using it for ~5 years there's very little I would change. The answer I gave was to use HLists rather than Tuples in the standard library, but that feels like a nitpick more than anything else)
[1]https://en.wikipedia.org/wiki/Missionaries_and_cannibals_pro...
Most people who think they could improve a language don't have any background in programming languages, don't have a good nose for what would actually be an improvement, and would actually screw it up badly. Having declined to shave that yak for years hardly means that someone is incompetent. Are you interviewing people to create new general-purpose programming languages? Do you often build new programming languages as part of projects? If so, you must miss deadlines a lot.
It's incredible to me how interviewing is in the stone age: some guy gets assigned to interview people because it needs to be done, and how hard could it be anyway? Then he Googles questions to ask, which are more or less arbitrary, and grades them more or less arbitrarily. And the same guy who asks is the one who judges the quality of the question, which is tied up with ego and confirmation bias. Over time, he adjusts to his own taste, but is accountable to nothing else. You get a process which, at best, selects people who are like the interviewer, because the interviewer assumes he is good, so other good people have backgrounds and opinions (and demographics) like his.
It's the same process that 10-year-old boys at a skate park might use to judge whether a new boy is a "poseur." It depends as much on whether the judges think the new boy is like them or dresses correctly or whatever as on any meaningful evidence of ability.
Will that do ?
The root issue here is the other interviewer and the apparent interview process.
>'In the post-interview pow-wow, all of the engineers who’d interviewed him gave him the thumbs up, except my interview partner except my interview partner, who refused to hire him...'
Yes, yes, optimizing for false negatives over false positives is all the rage, but this just sounds broken - wasting the efforts of a full panel only to accept an arbitrary single-question veto.
>'..on the grounds that he completely flubbed this question, and "any engineer worth his salt should be able to answer it."'
Good engineers don't necessarily make good interviewers. Outright excluding someone based on any single question is just horribly self-satisfied behavior.
It's the same principle which puts multiple men on a firing squad.
Everyone does know the joke about a camel being a horse designed by a committee?
And should not have the chair/leader of the committee over ruled the outlier anyway.
Even though they look like they're designed by committee, camels are an example of form following function. They're very well suited for their environment, and although they're stubborn, make good work animals.
A mustang on the other hand, is a feral horse. They're harder to domesticate because they've known freedom, and they've adapted to living in the wild by being smaller and more timid than horses selectively bred for doing work. If you really do need a horse, there are few cases where you need that horse to be a mustang.
If someone is hiring you because they think you're a mustang, you better hope they're caught up in the romanticism of cowboy stories instead of them being desperate for cheap labor or meat.
Of course that why history is full literally full of elite heavy camel units who turned the tide in so many battles and why Alexander's companions rode camels and of course the charge of the heavy camel brigade in the Crimea.
Certainly at British Telecom all people who sat on interview boards had to have done a two or three day residential course.
A very good point. Some people just forget that while solution can look simple when it's already known, actually finding it can be extremely hard and more akin to invention breakthrough. So such question is more similar to asking to prove some difficult theorem really, than to anything else.
Once, not that long ago, it was important to cover linked lists (and other data structures) because you'd have to be writing them in order to implement a program of any significant size. Now, though, all the common ones are already implemented for you (and to be honest, we don't even use LinkedList all that often---array-based lists are better in most real use cases).
So now their role in (my) CS2 is chiefly as setup. I still need to cover linked lists because they establish concepts that will be important when we get to trees (links) and to more general graphs (cycles and the lack thereof), as well as in operating systems (continuation inodes, memory allocation) and other areas.
But implementing an honest-to-god plain-old linked list holding ints or strings or whatever? Who does that anymore?
Write a program that starts at the head of the list and in a loop follows the "next" pointer on the current list entry, halting when the pointer is null. Run the program and wait. If the program never ends, there's a cycle in the list.
But we can test for programming ability directly.
Here's a file a customer sent you that describes their organizational hierarchy:
ID Name Manager
1 Alice 4
2 Bob 1
3 Charlie 8
4 Dave -
5 Elise 3
6 Fred 2
7 Gemma 1
8 Henry 5
Is this a valid hierarchical tree? Okay, it's not exactly the same problem, but it's certainly similar...But if I were to ask you to write a routine to find the root node for a given node based on that data, then ask you to guard that routine against finding yourself in an infinite loop or stack overflow, tortoise and hare would be a legitimate answer.
Just trying to make it clear that just because the question asks about linked lists, doesn't mean it's always about abstract data structures.
This problem can be also solved by building big set of already seen list nodes or adding bit to list nodes themselves. Whis is both something that everybody should be able to come up with and implement.
I think that this is in fact quite good interview question because while there is one non-obvious perfect answer, it also has some sub-optimal solutions that are pretty obvious and simple to implement.
If the interviewer asked the question and rejected anyone that didn't immediately answer with the tortoise/hare approach that's the fault of the interviewer, not the question.
I once met an interviewer who liked to use the "reverse a string" question, except he was expecting candidates to know the XOR trick. Suffice to say few, if anyone, ever got past his "filter".
Primadonna interviewers who use interviews as ego-strokes are a problem in our industry. It's where the stupid "why are manhole covers round" questions came from, and it's where these hyper-optimized algorithms questions come from.
Some questions are better than others here, specifically ones that have many correct implementations and varying levels of optimal-ness. I'm a big fan of asking for Fibonacci implementations, for instance.
Since this question can have different correct implementations, then I would not consider it a bad question to ask.
It's upon the interviewer to be open to different answers, evaluate them fairly and ask smart follow-up questions. "Ok, so what's the complexity of your answer? Do you think it's possible to do better?" or "Compare your answer with this implementation".
Were there any computer science graduate programs between 1955 and 1967?
You're not dealing with "hundreds and hundreds of minds", you're dealing with those minds who 1) heard about linked lists, 2) heard about or realized there was a cycle detection problem, and 3) devoted any energy to that problem as opposed to the myriad other problems available to a mathematics or electrical engineering graduate student. All of this has to have happened between 1955 and when the problem was solved in advance of starting to write the paper on it, in advance of publication of the paper in 1967. The paper also presumably included a proof of correctness that isn't being asked for in the interview.
The interviewee has the further advantage that they know there is an answer in the space of the constraints the interviewer has drawn. As they suggest less optimal solutions, those constraints get tighter, and the answer gets easier to find. If they have been through an undergraduate computer science course, they probably also have more familiarity with linked lists than most of the people attempting to solve the problem before 1967.
None of which is to say that failing to find the answer deserves disqualification - that's probably still unreasonable - but the picture is nowhere near as absurd as presented.
The point is why do you need to prepare for and regurgitate these silly answers that you will almost assuredly never ever ever use in your day to day job?
I know which engineer I'd hire. Then again, I wouldn't ask such useless questions in the first place.
I have been going through my own crises of interview question. My go to question for interviews which I have asked of about half a dozen candidates so far, wasn't completely flubbed only once. The only people I know who gave the good answers besides myself were my boss and our intern from MIT during mock interviews. I have been grading the candidates not on being able to write the solution in code like I intended, but on being able to come up independently with bits needed for the solutions. This has been quite unsatisfactory. How do I know if my question is too hard, or if something else is wrong, like prescreening of candidates?
I can't remember the actual hints. I blitzed through 3 or 4 naive solutions first. My favorite was using tagged pointers to mark visited nodes. Eventually through a combination of hints and exploration I got to the idea of using two cursors. At that point it was a simple constraint about which cursor would be in front of the other and if there was a violation of that constraint it could only be because of a cycle.
It made for a good interview, but there was good chemistry between myself and my interviewer. Any question would have worked in reality.
By the way, this was the question at my first interview ever, so I do remember it quite well.
PS: I interviewed many candidates since, and I would never ask such a question.
Me, I'd ask them this:
1. Write a function that takes a string of hex digits and converts them to a long (or equivalent in the language). Keep code minimal.
2. The opposite. Keep code minimal.
3. Write a function that reverses a UTF-8 encoded string (provide a good reference to the UTF-8 format), keeping combining characters in the reversed string in the same order they were in the original. I.e. aüç should be çüa, not ¸c¨ua. Assume the string of bytes is a proper utf-8 string, that only combining characters have to be order-preserved and that the only combining characters are the ones with unicode character codes in these ranges: (give them some standard ranges). Keep code minimal.
Anybody who can do these three things should be able to learn most any other tech stack you throw at them. If on the other hand you're looking for people with specific expertise with a given branch of computer science, then you need a different set of tests. The central question is - do you need a developer or a mathematician specialising in discrete mathematics. Those are two different sets of people, though they tend to overlap.
The optimal one, no but I didn't try any further than the solutions I had.
I'm an extreme novice to programming. I don't fully understand this.
1) How can you traverse a linked list two nodes at a time? Is this just short-hand for "go to the next node, then go to the node after that, and call that one operation"?
2) If you can detect when two pointers are pointing to the same address, couldn't you solve the problem by traversing the list one node at a time, storing the addresses of each node in an array, and checking to see if the array contains any duplicate values at intervals?
2) Yes you can do this but not in all languages.
"moving the goal posts" is called "every month at work, when you finish 1 task and then move on to another task, instead of going home and getting paid to rest on your laurels"
You want someone to answer a programming question within a particular set of boundaries, you set those boundaries.
"How you adapt in the face of additional constraints" is very much relevant to programming.
2) Yes, you could, and that is a valid way to discover a loop. However, consider that your linked list is already a store of the contents of the list. Rather than copying values out, you may as well use the list itself.
If you could assume that the loop contains all members of the list, then you could detect the loop by iterating through the list and checking to see if the node is the same as the head of the list. Unfortunately, the loop doesn't always point back to the head of the list, so you may have something like this:
1 -> 2 -> 3
| |
^ \/
5 <- 4
By maintaining two node references, and advancing one of them twice as quickly as the other, you are effectively doing the exact same check, but eliminating the problem that the loop may not include the head. In both tests, the separation between the two referenced nodes increases by one every time, but only in the second test is the "head" reference guaranteed to eventually be in the loop.I simply put down my pen, walked out of the room and told the recruiter if this company was hiring based on these type of questions I would be a terrible fit :)
I've been places with tough interviews and incompetent developers and the opposite as well. One does not necessarily correlate with the other.
In the past I've searched for various compendiums of algorithm interview questions and saw the cycle detection one come up. I knew I would never be able to solve such a problem on the spot. This blog post initially put it in perspective for me, that its pretty much a BS academic question that you have to already know the answer to - until I read the comments here, full of totally awesome alpha SV nerds who are saying "I instantly got the optimal answer without any foreknowledge". Now I don't know what to think.
Another answer is to mark nodes using the low bits of the next pointer. Also linear time, but also requiring clean up. I can see how not knowing c would cause people to think this question was somewhat unfair, but I didn't see it that way.
Edit: I would never expect anyone to actually remember or need to know that for an interview. It would be definitely something you would re-discover/discover because you had to run into it.
type a = b
type b = a
If a program has a structure like this with cyclic dependencies, then the compiler must be aware of this and break. (At least, I can imagine a situation where this could be a desired attribute.)
http://stackoverflow.com/questions/16436165/detecting-cycles...
This is at least very easy to reason about. However, if you are still right my thought process is just very wrong.
A linked list is a particular type of DAG (or at least DG). The relevant distinction between linked list and the general case is that a linked list restricts nodes to (zero or) one outbound edge. This is relevant to the problem at hand, because you only have one tortoise and one hare and so they can only follow one path.
That doesn't get around the original objection, though, which is that the restriction has to be exploited to get the algorithm in question, and thus the algorithm cannot be applied to the general case of graphs.
Having said that, certainly the ability to make use of restrictions provided by your domain is hugely valuable, and this should serve as a relatively familiar case.
But not in O(1) space, right?
I can imagine representing the graph as a list of paths, in which case the tortoise-and-hare algorithm is O(1) space, though the graph itself would be (potentially much) larger. Virtually every other operation on such a graph would take a performance hit, too.
There may be other factors I haven't thought of, but you're right that the generalized algorithm could not be as space-efficient as the special algorithm.
It's worth noting, though, that the original question poised in the article did not place an O(1) restriction on space.
For sure.
Let m = size_of_current_process / sizeof(list_node) + 3
Let np = pointer or reference to first node in list
while (np != null)
if (m-- == 0)
return HAS_CYCLE
np = np->next
return NO_CYCLE
[1] this approach might actually be acceptable in some circumstancesI think I'll take a pass on interview advice from this character.
If it indeed took 12 years for the algorithm to appear, it's likely because finding loops in a linked list isn't a very common problem, not because the algorithm itself is that hard.
Given that we didn't have the knowledge or tools necessary to make a compiler hundreds/thousands/millions of years ago, you'd have to bump up your start date considerably.
If you were referring to a more trivial algorithm (e.g. linear space), I think you misinterpreted what the interviewer was expecting and would not have gotten the job.
It's also worth noting -- esp if you're referring to the TH algorithm -- that CS curricula are not standardized and that there are probably dozens of "clever trick" algorithms you haven't seen and couldn't come up with on the spot (e.g. can you initialize an array in constant time?), but someone else thinks is trivial because they happened to see it in a lecture/read it online.
I would make a note that you did find one type of solution, of course.
edit: I would probably also ask why you created an api that even allows cycles, being as that you are defining control over adding and removing elements. Further, if you stated that your api explicitly allows cycles, I would ask why you don't simply mark them at insertion time and flag them, making the "detection" algorithm O(1).
1. Take a guess about how much memory the program has allocated so far. If you can't, go with 2^48 = 281474976710656 bytes - the maximum you can do on a 64bit pc today.
2. Divide by the minimum size of a list entry.
3. Traverse the list until the end or until you traverse more elements than there ever could be.
In general though, as noted, you'll know if you're making a list that could possibly contain cycles due to exposing an interface that allows the creation of cycles. In that case, given that you want to be able to efficiently detect cycles, you'd make a special linked list implementation that does keep internal count of its size.
Then I'd suggest you try the other way, but it's a perfectly good answer.
The problem is, in Java and probably many others, that method computes the size in linear time by traversing the list. The javadocs for java.util.LinkedList note that this was a decision taken so that splitting a list at an arbitrary node, etc. could be a constant-time operation.
1.https://www.cs.purdue.edu/homes/cs240/lectures/Lecture-7.pdf
In which case, no, everyday programming is mostly not about designing algorithms. Otherwise, programmers would spend most of their time with journals and books, with a few days of programming each month.
Interesting is a social construction. As such, I would define interesting as worthy of publication in a first or second-tier conference at some point in the history of the field.
> If you cannot demonstrate ability to solve a simple, well trodden problem how will you be able to solve a new one?
0. I've seen many well-respected researchers who have solved truly interesting, new-to-humanity problems stumble on well-known problems others consider easy and/or fundamental. In fact, this is probably true for every single researcher. And doubly so for practitioners. One person's fundamental technique is another's blind spot.
1. Simple != easy to come up with. Often exactly the opposite! Take the TH algorithm as an example. It's a very simple algorithm. Small. Simple. Optimal. Awesome. Not trivial to discover, however.
2. Well-trodden -> unless the algorithm is absolutely fundamental and taught everywhere (e.g. sorting), you've given up on testing problem solving skills. You're just testing whether the person's intro/DS/algo professor covered this particular algorithm (and maybe their memory). Or, more likely, rather their random interview studying happened to hit your pet problem. Since curriculum is not anywhere close to uniform in CS -- even among top schools -- this is just silly.
3. Simple problems don't always have (simple) solutions. Create a fair voting scheme.
If not, can they solve it with a naive method and then make reasonable attempts to iterate on that, even if they never hit an optimal solution?
It is a little like a high end restaurant asking a trainee chef to make an omelette, which is apparently common in the culinary industry.
I think the author of the article is indicting situations where this is the case. Perhaps he could have been more explicit up front, but reading between the lines this is the situation he's complaining about.
> If not, can they solve it with a naive method and then make reasonable attempts to iterate on that, even if they never hit an optimal solution?
If I were asking the question, absolutely.
> It is a little like a high end restaurant asking a trainee chef to make an omelette, which is apparently common in the culinary industry.
Are there omlettes that are "optimal" (very awesome in some sense)? I honestly don't know (and if so, man, I want one!)
I miss the old times when these puzzlers were asked during interviews. My theory is that you can recognize an excellent place of work with a great future when they actually ask you these sorts of questions as it attracts certain kind of excellent and creative people. I could see the "interestingness" of companies being shifted as they abandoned these questions, first Microsoft (picked up by Google), then Google (picked up by Facebook), like they were passing some kind of "greatness" token (MS->G->FB).
I was told at Google that I solved two problems like this during an interview that nobody solved before me in 15 minutes (one led to a super complicated math formula and dynamic programming, the other I solved optimally but differently to their solution, and provided an optimality proof based on discrete calculus). It was the greatest and most challenging interview in my life. I miss it, all interviews nowadays are just boring as hell :-/
They saw my own open-space real-time software 3D rendering engine with texturing and shading (C++/Asm) at SourceForge already, they saw my own SQL server (many students at my first university were ripping it off for their own class projects in the next years so it was a mistake to make it open) as well as other projects I did prior to that interview so they were familiar with my coding style and quality.
Also, before that while working at SUN I did some work on a test suite with 10,000s of tests, many of them for SUN's own compliance with one of their standards, making sure it was executing on a distributed cluster every day for every branch they had in order to ship the best quality to customers. Many of these tests were for obscure cluster failure cases using custom bleeding-edge test frameworks. So the answer is no, I didn't write any test at Google interview, it wasn't required.
How can you prove you can code in a team during an one-on-one interview? At best you can give hints that you are willing to discuss stuff and change your progress on input from the interviewer and explore if there is any sort of chemistry between you two, which is about all you can do.
I really hate this kind of nitpicking, averaging everyone to a "normal" level, trying to find something wrong in someone because she or he goes against (IMO) lazy typical stereotype. Enjoy your mediocrity! Are there still hackers on HN?