65

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
  • 46
    No, this is an elementary task. You did good filtering this guy out.
  • 29
    Just a loop through a list and find the largest item?
    Literally just that?
  • 22
    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.
  • 3
    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.
  • 1
    @Fast-Nop what role HR plays then?
  • 8
    @hashedram holy jesus that doesn't exist what the hell.
  • 4
    @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.
  • 3
    @Fast-Nop AFAIK HRs and Recruiters are solely responsible for filtering the right candidates and taking then to hiring managers.

    Tech recruiters scan and grill real well.

    Lately I have been asked more difficult questions by some HRs than hiring managers.
  • 9
    @F1973 I doubt that anyone in my company's HR can even tell a C compiler from a hole in the ground.
  • 1
    @Fast-Nop technical screening and technical round are two different things.

    Filtering and shortlisting is done by HRs/Recruiters.

    Then candidates are grilled in technical round.
  • 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".
  • 1
    But you already told him to loop through the list. 😬
  • 7
    I would say that if you’re relying on Google to help you write a loop and one line of logic after 12 years then maybe you should reconsider your life choices.
    Wonder what actual dev work he’s been doing all that time
  • 8
    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.
  • 6
    @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.
  • 5
    @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.
  • 5
    @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.
  • 5
    @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?
  • 0
    What??? He couldn’t do this?
    ptr=head
    ans=smallestnumber
    while ptr!=null
    ans=max(ans, ptr.val)
    ptr=ptr.next
    return ans
  • 1
    foldl1 max
  • 1
    But yeah, while we typically start the tech interview with harder questions these days, I used to always open with: whiteboard in pseudocode/C/whatever an integer factorial function.

    And then we'd go from there.

    Had one candidate who was an _excellent_ blagger, but could not write a for loop. In pseudocode or otherwise. Applying for a scientific software engineering role.
  • 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...
  • 5
    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.
  • 0
    No you are in the right. So many devs are copy paste devs. When they get into things not answered on stack overflow they cannot function.
  • 0
    @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...
  • 2
    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
  • 3
    @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.
  • 1
    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.
  • 1
    @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...
  • 3
    @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;
  • 0
  • 0
    @electrineer But what if it isn't the first one?
  • 2
    @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.
Add Comment