6 ms·
Hypothetically, if when asked this question in an interview I were to reply "I'd look up the canonical solution on the internet and just implement that. I have
by JonnieCache 12y ago
Hypothetically, if when asked this question in an interview I were to reply "I'd look up the canonical solution on the internet and just implement that. I have better things to keep in my brain than linked-list algorithms, and there's no way I'm going to beat decades of phd work off the top of my head", what would happen?
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.
- _mulder_ 12y agoA great response would be to just say "hold on", whip out your phone and Google the answer, show it to them and finish up with "How long did it take your other candidates to complete that task? next..." 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.
- JonnieCache 12y agoI think it would be funnier to silently transcribe the code from the phone to the whiteboard, and then just sit back down and look at them while you wait for a response.
- jiggy2011 12y ago"oh, you can use google. Surely none of the other candidates could think of that"
- TheOtherHobbes 12y agoThe professionals use StackOverflow.
- colanderman 12y agoMy response would be, "OK, walk me through the code, show me how and why it works, or if it doesn't (code from teh Internets is buggy), fix it." Anything higher than a junior position requires maintaining code as much as, or more than, writing it. Maybe this points to a better class of interview questions: the interviewer supplies the broken algorithm, the interviewee supplies the bugfix.
- dllthomas 12y ago"Anything higher than a junior position requires maintaining code as much, or more than, writing it." I think that applies to junior positions, too.
- colanderman 12y agoYou're correct, but generally when critical thing X is broken and you need it working for the customer, you give it to your more experienced devs, not the college intern.
- dllthomas 12y agoTrue, but when I'm in a more senior position, we're less often in a situation where critical thing X is broken.
- angersock 12y agoIf an interviewee had the stones to try that in an interview, I'd probably have to at least give them a golf clap.
- notjosh 12y agoI did something like this recently. The question was more around increasing efficiency of an algorithm though, and on top of what you said, the other part of my answer was more like "I wouldn't waste my time as long as performance was acceptable until it became an actual problem at larger scale. I'd move on to shipping other features." 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.
- vinkelhake 12y agoThat's probably fine if you're going for a junior position where your job is to bang out code for designs that others have come up with. 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.
- JonnieCache 12y agoOh I agree. That's exactly the stuff I keep in my brain instead of linked list algorithms, which have a mathematically proven optimal solution. Remembering them when I don't use them regularly would be a waste of brainpower which could be better used for solutions to business/UX/architecture problems, which one cannot solve with pure logic.
- boomzilla 12y agoI am not so sure. It's not just about solving the problem, but sometimes it's also the willingness and mentality to tackle something that's outside your comfort zone, as well as the approaches. 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.
- JonnieCache 12y ago(Just to be clear, as this is a permanent and public record, I'm perfectly capable of doing this kind of thing. It's not really an unreasonable question to ask. I'm just being facetious because it's friday afternoon.)
- SilasX 12y agoI agree: the hard mental work is in recognizing that a fuzzy, client-provided problem description is merely a disguised form of a well understood problem -- ie, getting it to the point where you can google easy solutions at all. 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".
- walshemj 12y agoBut that solves the problem no? its like when I needed to limit a tool I wore to so many api requests in an hour I knew I needed a queuing algorithm but I don't keep that in my head a couple of quick google queries and a quick look on CPAN problem solved.
- mrfusion 12y agoI tried that once and was told "we don't use freeware here".
- walshemj 12y agoah so what do you use instead of TCP/IP then :-)
- alok-g 12y agoOne day interviewers will realize this. Caching into your mind what's one stackoverflow away can often be an invalid optimization. >> 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.