5 ms·
Consider the fact that coding under pressure is hard and it probably doesn't mean that the candidate is incapable of merging two sorted lists. Right now I can t
by _RPM 10y ago
Consider the fact that coding under pressure is hard and it probably doesn't mean that the candidate is incapable of merging two sorted lists. Right now I can think of a way to do it:
var ar = [];
ar1.map(function() { ar.push(arguments[0]); }
ar2.map(function() { ar.push(arguments[0]); }
However, under pressure it's so much different than responding to a comment. This is for sure a great question to ask.
- jaredsohn 10y agoFYI, this doesn't merge two _sorted_ lists. The correct answer would be to loop while neither list is empty and always put the smaller element into the new array and remove it from the original list. Then you iterate over each of the lists individually (one of them will already be empty) and copy over the remaining elements at the end. Edit: See http://stackoverflow.com/questions/5958169/how-to-merge-two-sorted-arrays-into-a-sorted-array http://stackoverflow.com/questions/5958169/how-to-merge-two-... for some solutions (in one of the answers there, they made the same mistake.)
- _RPM 10y agoOh shit. I just failed the interview then. I'm just not that smart, more of a code monkey type, not really a mathematician computational type programmer. I want to be better, but I think I'm just cut out for line of business type things where you don't need any CS knowledge even though I will have a CS degree soon.
- wutbrodo 10y agoThat's what I mean, just because the question is abstracted to be pure numbers doesn't mean that it's mathematician computational type stuff. This is a basic enough task (data structures, iteration) that someone who can't do it wouldn't meet any reasonable definition of "knowing how to code". By the way, I don't think that group includes you: I'm quite sure you'd be able to pass it in an interview context. You'd probably be paying more attention to the details of the question in an interview and I usually give sample input/output to reduce the chance of a candidate accidentally overlooking a word in the question.
- lazaroclapp 10y agoI would correct to 'any reasonable definition of being a professional software developer'. There are tons of programming tasks that require coding literacy but do not require even knowing what a linked list is (e.g. simulations written by really smart people pursuing a Physics Ph.D., perl scripts done by wise UNIX-beard sysadmins, etc). That said, I agree this is a reasonable sanity-check test for someone who is asking about a developer job at a software company, and I also agree that it is easy to make mistakes in commenting an off-the-cuff answer to it on an online forum that one wouldn't make in a real interview. I mean, I've gotten 3rd grade arithmetic wrong in my own HN comments before! ;)
- tomp 10y agoThey're not necessarily linked lists, could be arrays as well. I can't really imagine any physics PhDs not knowing how to index arrays...
- jaredsohn 10y agoI think you misread the GP; the GP was stating that there are probably physics PhD students who do fine without knowing linked lists. I think you are right that knowing how to index arrays would be a necessary skill for them.
- wutbrodo 10y ago> There are tons of programming tasks that require coding literacy but do not require even knowing what a linked list is I think people are assuming that I force the candidate to do this in C or something and munge about with next pointers and sentinel nodes. They're free to do so if they'd like, but usually they have a pretty high degree of control over what language they use and in this problem, what data structure it starts in (including arrays). As mentioned upthread, that means the problem literally reduces to something like loops, iteration, conditionals, collections. These abstractions are fundamental enough that again, any reasonable definition of coding includes them. Physics PhDs writing simulations occasionally have to deal with more than one particle (or whatever), and if they have no clue how to "do X for every Y", they won't get very far. This isn't just hypothetical for me: I've interviewed PhDs (including non-CS ones), and pretty much all of them blew past this first filter. I've worked with people whose only prior programming experience was during their math PhD, and they generally were pretty great at programming (and pretty horrible at engineering). The latter is easy to teach (this guy became one of my best engineers) but the former is much more fundamental, much harder to teach, and generally something you want at time of hire.
- mikekchar 10y agoI hope I can encourage you to think of yourself in a different light. You made a mistake. Grab the code you wrote, write some test data and see what it does. Fix it. It just takes practice -- over and over and over. Since you say that you will have CS degree "soon", I'll assume you are fairly new to programming. Making mistakes is something that you will do for your whole career. A mistake does not make you one kind of programmer over another. Even many mistakes does not. It just means more practice. Having the courage to post code off the top of your head in a world-wide forum, means you can have the courage to transcend where you are now. Keep trying to improve -- whatever it takes, and don't unnecessarily limit yourself.
- hvidgaard 10y agoI interview people. I don't care at all that they make a mistake. I want to get into the candidates train of thought, and see how they react to feedback. If you made a mistake like that it would be excellent for that purpose. You showed comprehension of lists and basic problem solving, so you're already ahead of the midfield.