77

I was interviewing this guy who's been a dev for 12 years. Apparently got laid off in his small town company because of covid.

So I asked him to write an algorithm that loops through a list and returns the largest number.

Not only could he not do that after trying for 15 minutes, but he also spent an entire minute ranting about how algorithmic questions were dumb and unnecessary in this day and age and you can google these things without having them memorized anyway.

The point of an algorithmic question in an interview is not to see if you can memorize the fucking thing. It's to see if you're methodical enough to reason through what you don't know and arrive at a decent solution all the same.

What do you guys think? Was I somehow the asshole here? It was a JavaScript job and the product was fairly complex, not just HTML bullshit.

Comments
  • 55
    No, this is an elementary task. You did good filtering this guy out.
  • 39
    Just a loop through a list and find the largest item?
    Literally just that?
  • 28
    That guy is the reason why such a super easy "algo" question makes sense - to filter out idiots who can't even code their way out of a wet paper bag. He would have failed the infamous FizzBuzz test as well.
  • 2
    Um..pseudocode ok? Or would you be nitpickin at the syntax (had he produced any code)?

    Also you mentioned js job..js doesn't have a list per se..maybe this weirded him out? //jk

    Anyhu, imho it's him being the weird one here..
  • 3
    @Ranchonyx literally just that. It's India.
  • 8
    @sladuled Don't worry, I used the term array and yes, pseudo code was perfectly fine. I don't nitpick.

    He never got past the for loop. Spent 5 minutes staring at the ceiling.
  • 8
    @hashedram holy jesus that doesn't exist what the hell.
  • 2
    @F1973 It's not their job to judge the tech aspects of the candidate. Only tech staff can do that.

    Their job is e.g. to negotiate contract conditions and give their opinion whether the candidate would fit in the company.
  • 8
    @F1973 I doubt that anyone in my company's HR can even tell a C compiler from a hole in the ground.
  • 6
    NTA.

    It's a totally fair interview request.
  • 0
    Sounds like 5 years old, unless he's clearly 13 and up, considering the imaginary years of "experience".
  • 7
    I mean... I live and die by stack overflow.

    But still I could do a simple sort in any of about 15 languages without having to google anything.

    Especially when it's in JS...

    There's literally a built in sort function called fucking sort() whose default behavior would return the list you need.

    Like even knowing nothing about programming at all...

    I wonder if array.sort() will work?

    Yeah... yeah it will.

    That dev was just shit.
  • 1
    I@F1973 HR can do their best to screen resumes but a lot of desparate people lie on their resumes. Especially in markets where there aren't enough jobs.
  • 5
    @HiFiWiFiSciFi no I specifically asked him to loop through the thing. There's no point in asking someone to call a sort function that exists. That gives me no useful info at all. But looping through a list and storing the largest is hardly a difficult task.
  • 4
    @hashedram oh well then I suppose it's a little harder.

    But still bubble sort is like day one stuff for any average programming class.

    I'll wing it in ES5 right here:

    var lastVal = 0;
    var max = 0;
    for(var i = 0; i<array.length; i++) {
    if(array[i] > lastVal) {
    max = array[i]
    }
    lastVal = array[i];
    }
    console.log(max);

    Took about 90 seconds... should run.
  • 4
    @HiFiWiFiSciFi I know. The issue is that in my country, there's a lot of shitty low quality sweatshop companies that sit around doing wordpress and pretending to be IT. Which means there's a lot of people who call themselves experienced devs who've never actually written code.
  • 7
    @HiFiWiFiSciFi Why are you even interested in last val? 🤔

    Am I missing sth here?!

    Wouldn't it be enough just to check and set max?
  • 1
    What??? He couldn’t do this?
    ptr=head
    ans=smallestnumber
    while ptr!=null
    ans=max(ans, ptr.val)
    ptr=ptr.next
    return ans
  • 5
    When I interview (I've done hundreds over the years) I like to ask one or two basically straight-up "disqualifying" questions. I don't care about an exact right answer, but ANY developer worth considering should be able to at least stumble their way to something that looks LOGICAL at least. It basically just proves that you've actually written code, because I've interviewed some people who I suspected never actually had despite their resume. So I have no problem with the question you asked. If you can't even give me a for loop (and pseudocode would be fine) then that's a BIG red flag. I hate whiteboard algo questions too and I don't ask them, but this is nothing but a "are you outright lying on your resume" question as far as I'm concerned. And, hey, if you want to tell me you hate algo questions, that's fine - like I said, so do I - but you damn well better be saying it AS YOU'RE WRITING A FUCKING LOOP OF SOME SORT!
  • 0
    @sladuled Yup... that would be faster with one less variable write per loop. I did say I was winging it...
  • 4
    That sort of basic questions about algorithmic thinking are crucial in assessing basic suitability for any actual development role.
    Someone who isn't able to think of a way to get the maximum of a set of numbers, will have an absurdly hard time doing anything apart from the most basic scripting tasks and chaining stackoverflow answers together.

    It doesn't even matter whether he claims having experience or not. You have to be able to think about a problem before you can become able to translate the result into code.
  • 0
    I've ranted before about algorithmic questions. However, in this case the question is so trivial it might be considered general knowledge. The guy's not at all ready for working professionally. Your pat on the back, as requested.
  • 1
    @hashedram Heh... I thought of a "better" way that uses sort, but also loops through the array.

    for each(array) {
    array.sort();
    }

    I mean, yeah, it sorts the thing (array.length-1) too many times... but it will spit out the right answer... and it did meet the requirement of looping through the list...
  • 1
    I really find this baffling, there is some miss information here a 12 years experience dev will never fail at such an elementary task,
    I think either he is not 12 years experienced or he is going through some personal shit that’s affecting his capabilities
  • 2
    @hashedram lol, "it's India" explains everything
  • 0
    @hashedram
    If the job pays more than $1600 per month and the job is good/satisfying, please let me know how to apply.
  • 2
    Well... if sort() is allowed then

    array.sort().pop()

    is one of the shorter variants, no loop needed....

    Another is array.max()

    5 small lines of pseudo ruby does the trick

    max = INT_MIN
    arr.each do |num|
    max = num if num > max
    end
    puts max

    🤷‍♂️
  • 1
    @RagingCodeChimp Not only that it wasn't allowed, sorting the array has even O(N log N) instead of O(N). Fail.
  • 2
    @Fast-Nop nobody said anything about runtime 😊
  • 1
    @HiFiWiFiSciFi arr.reduce((a, b) => Math.max(a, b));
  • 3
    Thanks for the story!
  • 0
    @spongessuck @Ranchonyx Honestly off the top of my head I have no clue on how to write that...
  • 8
    @linuxxx
    @highlight

    largest_damn_number = first_of_your_filthy_numbers;

    for a_fucking_number in your_filthy_numbers
    {
    if largest_damn_number < a_fucking_number
    largest_damn_number = a_fucking_number;
    }

    return largest_damn_number;
  • 1
  • 0
    @electrineer But what if it isn't the first one?
  • 4
    @linuxxx cmon dude, are you trolling?
  • 0
    @electrineer Nope, fucking tired but I honestly have never done this one without a sort or so.

    My point (apart from the fact that I literally wouldn't know how to do this task) is that something that might seems fucking simple for someone, might be hard for another person.
  • 0
    @linuxxx That's the initialisation, and using a for loop, you'd go from the second number onwards. Also, the whole point of the test is to filter out people for whom writing a for loop is "hard".
  • 1
    @linuxxx I guess it tells a lot about your background
  • 1
    @linuxxx You don't actually need to know programming to solve the problem. If someone handed you a bunch of cards with a number on each them and asked you what is the largest number, would you sort them all? You have to go through them all, but you have to only memorize the largest value you have seen.
  • 0
    @electrineer Not entirely sure what you mean by the background comment?
  • 0
    @linuxxx You're missing the entire point. You're not supposed to have this stuff memorized. But if you can't loop through a list of things and compare values against a stored variable, there isn't much else to work with while building the sort of things I work with, which are at least a thousand times more complex. You're supposed to try it out on a whiteboard or an editor and figure it out.
  • 0
    @linuxxx I pulled my solutions to the assignments of my first programming course. It was for complete beginners and taught in python. On the 17th assignment, I looped through a dictionary to find the largest of the items. Surely you have started from somewhere else if that doesn't come to your mind immediately. That's what I meant with different background.
  • 1
    @hashedram Honestly, with this stuff I've always done automatic sorts and stuff. I do get the point but I guess I just never was in a situation where these kind of manual algo's were necessary?

    @electrineer Gotya. I thought you meant level of education/IQ and such and since those are not THAT high in my case, I interpreted your comment wrong and kind of saw it as a personal attack (which was my mistake)
  • 1
    @linuxxx I remember an application with arrays that needed to be handled from large to small numbers. So I sorted.

    Upon profiling, I noticed that in about 50% of the cases, all I needed was the largest element. So I went through the array with a for-loop and swapped the largest found element to the top, exactly the thing from this rant. Only if that turned out to be among the other 50% of the cases, I sorted the rest of the array.

    Result: the time spent in sorting dropped to half of what it had been before.
  • 0
    @linuxxx I was actually trying to reason that you can still be competent in what you're doing even if something from a beginner's programming course doesn't cross your mind. You just have a different background.
  • 0
    @linuxxx let me put it this way

    When you're a baseball player, it's never going to be necessary to walk onto a field and do push ups. But if you're applying to be a baseball player and you can't do a single push up, you're probably not a good player.

    I know these no one needs to use these things in every day programming. That's irrelevant. You either have the logical fortitude to figure it out or you don't.
  • 0
    It was a fair question.
    But we should always keep in mind that having to write code during an interview can be such a stressful and unnatural situation for some developers.
    If you are used to solo coding, debugging your code, googling etc on your own time - you might be a great developer when you get to do things your way - but break down under pressure if someone is watching over your shoulder or gives you a time limit to solve something without your usual tools.

    I usually ask if the candidate is nervous and if they are - I take that into account.

    But hey - if someone says they are not nervous and get stuck on a simple task like this - then there's something lacking.
Add Comment