News for hackers. Stuff that matters.
Re:Lessons learned from the recent job hunt by umvi on Sunday May 08, 2022 @12:49PM (#31305722)
I feel like a lot of leetcode grinders don't actually understand big O. Sure, they will produce the correct answers to your questions like a well-oiled Chinese Room, but they lack true understanding. It's almost mechanical: "O(1) is faster/better than O(n) which is faster/better than O(n^2)" etc. O(1) is hashmap, O(n) is a for loop, O(n^2) is a nested for loop, etc.

So if an O(1) solution exists, the candidate will almost certainly converge on it. Yet the part not being understood is that big-O is just an upper bound that you may never see unless your datasets grow to huge sizes. Sometimes an O(n) implementation is actually better or faster than an O(1) implementation or sometimes O(n^2) is better/preferable than O(n). It depends on a lot of things - the size of the data being handled, the expected scaling of the data, who is going to be maintaining the code, etc. A straightforward, highly readable O(n^2) function that operates on small datasets is almost certainly preferable to an unholy O(n) incantation that is unreadable but technically scales better.

Re:Lessons learned from the recent job hunt by PheonixPharts on Sunday May 08, 2022 @01:17PM (#31305997)
> well-oiled Chinese Room

Wow, this is really the perfect description of the general understanding of algorithms and computational complexity in the post-leet code era.

I've found that far less people in software understand and are curious about algorithms than there were 15 years ago, despite the fact that almost everyone studies them now for interviews.

I wonder how many people asking questions about computational complexity could tell you what the pumping lemma is, or how a regular language differs from pushdown automata. Or, more important, if they could answer the question "what is Big Omega for this problem?" or if they are really asking "what is big theta?". I'm still tempted sometimes to refresh on recurrence equations to provide the actual answer for these things rather than just applying some heuristic. Of course, in my experience, doing something like that would get you a failing score since they wouldn't know what you're doing and therefore assume you are wrong and an idiot "I can't believe that guy didn't even understand Big O".

Re:Lessons learned from the recent job hunt by eastbound on Sunday May 08, 2022 @01:59PM (#31306409)
> I've found that far less people in software understand and are curious about algorithms than there were 15 years ago, despite the fact that almost everyone studies them now for interviews.

It may explain why no-one succeeds my interview test, but then I wonder what I should test on if I want someone correctly smart.

My interview test is simply to find a string in a string and return true. It takes two for and one if, everyone fails, I generally stop them after one hour when there are booleans scattered everywhere. The way I give the exercise is “Please program a .contains(), without using .indexOf(), and no need to optimize anything, I’m not looking for anything fancy.” A 49 years old java programmer even complained that the test isn’t fair because it’s stressful to program in front of people, so now I take the habit of sitting in the next room, but then people try to overdo it and deal with UTF-8 before having the basic algo working.

I’m pulling my hair wondering what’s this parallel world I’m in, or whether I’m introducing a bias which makes everyone fail (2 interviewees per month for 5 months).

Re:Lessons learned from the recent job hunt by weaksauce on Sunday May 08, 2022 @03:37PM (#31307419)
Either you aren't screening candidates that have no obvious coding skills or the job description is wildly off the mark. That's a pretty easy coding test for basic strings.
Re:Lessons learned from the recent job hunt by Beldin on Sunday May 08, 2022 @03:19PM (#31307252)
> ...I wonder what I should test on if I want someone correctly smart.

Why would you want that? Look for someone who can (and is happy/eager to) learn *from you*.

Edit: smart isn't bad, but it's not much of a signal - there are plenty of ways to be smart but not very productive. Moreover, any test in an interview setting well be extremely limited. Ability & willingness to grow seems a lot more useful (and at least equally well testable).

Re:Lessons learned from the recent job hunt by Gunax on Sunday May 08, 2022 @02:09PM (#31306502)
If they are over-complicating it, then you are not communicating the problem well.

Maybe change the problem to an array of ints. It's the same solution but you will not have anyone asking about UTF and text direction.

Re:Lessons learned from the recent job hunt by justinlloyd on Sunday May 08, 2022 @02:28PM (#31306705)
> “Please program a .contains(), without using .indexOf(), and no need to optimize anything, I’m not looking for anything fancy.”

If that is the statement that was given to me, I would clarify the interviewer is not looking for optimal run-time or anything fancy like handling UTF-8 or right-to-left -- because an interviewer often says "nothing fancy" and then will nitpick the fact the code you wrote on the whiteboard doesn't follow precise PEP-8 standards or use idiomatic Ruby or doesn't adhere to the latest C++-23 syntax -- and then I would write a total of six or seven lines of code C code (variable declarations, return statement, etc), which would be two for-loops and an if-statement. I could probably get that down to just the for-loops if I want to be "fancy" and bury the conditional in the for-loop test itself.

I think the real problem is, we tend, in an interview situation, to overthink what the interviewer is asking for at times. I see this in a lot of take home tests people do when applying to companies, then ask me if they have done enough before submitting to the company they are interviewing with. That said, I've dealt with interviewers that give the take home test, or the white board test, and then complain that the candidate didn't go far enough by adding on un-asked for stuff. "Going the extra mile" as they say. The crux of the problem is the vagaries of interviewing style.

Re:Lessons learned from the recent job hunt by weaksauce on Sunday May 08, 2022 @03:40PM (#31307446)
I think a lot could be mitigated if interviewers supplied a take home test and a different example take home test with an answer that showed the format of what they were actually looking for with depth/complexity/testing/etc.
Re:Lessons learned from the recent job hunt by akhmatova on Tuesday May 10, 2022 @12:10AM (#31323360)
A 49 years old java programmer even complained that the test isn’t fair

And you had to mention their age ... why, exactly?

As opposed to "a left-handed Java programmer", or "a Java guy wearing a Slayer T-shirt"? No -- for some reason, with this candidate -- their age was especially relevant to you.

Why?

But then people try to overdo it and deal with UTF-8 before having the basic algo working.

Because of one too many experiences with live coding interviews, (on appearances) pretty much exactly like yours -- in which one gets flushed (or otherwise dinged) for failing to proactively treat such edge-case details as encoding gotchas, zettabyte-scale strings sharded across multiple time zones, etc.

I’m pulling my hair wondering what’s this parallel world I’m in, or whether I’m introducing a bias which makes everyone fail (2 interviewees per month for 5 months).

In fact, you are introducing just such a bias. There has recently been good, solid research done into the fact that performative (that is: on a whiteboard, in front of a group) "programming" tests are really basically high-pass anxiety filters. That is, implicitly designed not to measure programming ability, but the (studied) ability to ... successfully complete peformative rituals in front of random strangers you've never met.

If you aren't aware of this research (or your capacities for empathy aren't at a level where this is intuitively obvious to you) -- then you shouldn't be conducting these kinds of interviews in the first place. No matter how good you are at programming per se.

Re:Lessons learned from the recent job hunt by PheonixPharts on Sunday May 08, 2022 @02:30PM (#31306725)
> A 49 years old java programmer even complained that the test isn’t fair because it’s stressful to program in front of people, so now I take the habit of sitting in the next room

Whether programmers like it or not, live coding has become a standard for interviews these days. I can see anyone still unfamiliar with this doing poorly, I used to do awful at these until I realized this is just part of the game, but it's not unreasonable to expect candidates to be able to do whiteboard/live coding.

However, you just sitting in the other room, tells me you also have a lot to learn about the structure of live coding interviews. Every major Big Co. that does these has a very well established flow, including providing helpful clues to the candidate. Most companies provide training to all interviewers to make sure this process is smooth, repeatable and fair to candidates.

Common tips are to: first make sure the candidate understands the question, make sure they are thinking out loud the entire time. You don't let the candidate go too far down the wrong path. Most important you have a list of anticipated questions with stock answers to help stuck candidates, as well as a list of stock prompts to help them get on the right track if they are lost.

For example, in your challenge, if a candidate is stuck you might ask as simpler subproblem "so how would you find out if a sting contained the letter 'a'?" and if a candidate starts heading down the wrong path, prompt with "hmmm... I think I see where you're going, but I recommend you back up a bit and rethink this part here"

It sounds like you're in a small shop so I highly recommend you enlist a few friends (especially some that have done interviewing at large companies) to help you work out the kinks in the interview itself.

Re:Lessons learned from the recent job hunt by TacticalCoder on Sunday May 08, 2022 @06:34PM (#31308685)
> ... but then people try to overdo it and deal with UTF-8 before having the basic algo working.

Wait... We all know (?) that Java was conceived before Unicode 3.1 came out and somehow thought that 16 bit chars would forever be enough to hold unicode codepoints and hence Java strings are now a mess of both char and codepoint methods but... What's UTF-8 got anything to do with your question, even after a basic algo is working?

If I'm using Java's charAt(...) on both strings, what's the encoding got anything to do with matching if the substring is present? Who cares that one character may have a codepoint encoded using more than one Java char primitive? It's either encoded the same in both strings or it won't match right?

I'm confused.

EDIT: you said it's not fancy, so you're not looking for people to match combining codepoints in one string matching another codepoint in the other string or things like that right?

Re:Lessons learned from the recent job hunt by akhmatova on Tuesday May 10, 2022 @12:44AM (#31323538)
What's UTF-8 got anything to do with your question, even after a basic algo is working?

ربما يجب عليك التفكير أكثر قليلا في السؤال.

Re:Lessons learned from the recent job hunt by foobarian on Sunday May 08, 2022 @05:56PM (#31308479)
Hey! That's my question :-) I've been doing pretty much exactly this for the past 10 years. A common solution I've seen is a single while loop with gnarly logic inside to monkey with the string index, rewind when no match, etc. Then imagine that kind of code in your business critical backend.
Re:Lessons learned from the recent job hunt by throwanem on Sunday May 08, 2022 @05:22PM (#31308255)
If you've just failed ten interviewees in a row, then either your sourcing is broken, or you're doing interviews wrong. Might be both, can't be neither.

Granted, I don't think it's all that hard a problem, and while I'm not at keys to check I think off the top of my head it should be solvable for constant strings in linear time - not like you're asking for sequence alignment or anything like that.

But if it demonstrates something relevant to the role and ten in a row can't hack it, then your pipeline's not finding you good candidates and that needs to be fixed.

And if it's not relevant - which is highly plausible, as who ever needs to or even should reimplement heavily optimized standard library functions, especially for as hairy a type as strings - then why even ask it in the first place?

edit, at keys: Yeah, it's simple to do this in linear time with constant strings (ie no backtracking):

    const cases = [
      {
        subject:
          "now is the time for all good men to come to the aid of their country",
        searchFor: "n to come t",
        expect: true,
      },
      {
        subject:
          "now is the time for all good men to come to the aid of their country",
        searchFor: "time flies",
        expect: false,
      },
      {
        subject: "short skirt",
        searchFor: "looooooooong jacket",
        expect: false,
      },
      {
        subject: "symbolized as ∆v and pronounced delta-vee",
        searchFor: "∆v",
        expect: true,
      },
    ];
    // TODO cases covering match at start and end, etc
    
    function contains(subject, searchFor) {
      let searchIdx = 0;
    
      for (let i = 0; i < subject.length; i++) {
        if (subject[i] === searchFor[searchIdx]) {
          searchIdx += 1;
    
          if (searchIdx + 1 === searchFor.length) {
            return true;
          }
    
          continue;
        }
    
        // We found a mismatch between subject and search
        // strings. Return to the first char of the search string;
        // we'll have to try to find a new match
        searchIdx = 0;
      }
    
      return false;
    }
    
    function assertEqual(expected, actual) {
      if (expected !== actual) {
        throw new Error("Assertion failed");
      }
    }
    
    cases.forEach((testCase, i) => {
      const { subject, searchFor, expect } = testCase;
      try {
        assertEqual(contains(subject, searchFor), expect);
        console.log(`PASS: case ${i + 1}`);
      } catch (e) {
        console.error(`FAIL: case ${i + 1}`);
      }
    });
It's trivial in quadratic time too, of course, although I would expect a candidate for a senior role to be able at least to find the linear solution, if not to start there outright.

In entire fairness, I have to admit that we do use problems of similar complexity (both cognitive and algorithmic) for our first tech session, which I frequently administer. In my experience, people tend to handle stuff like that pretty well, even with considerably less experience than it sounds like your candidates have. But - and I think this is crucial - none of those problems involves operating on strings.

As another commenter here suggested, you definitely need to express this in terms of Array<number> or some similar contrived type that's obviously not as complicated as strings, because anyone who's been around for a while will certainly have been burned often enough by string complexity that they're not likely to assume they can treat it purely as an array of bytes iso8859-1 style. I certainly wouldn't assume that!

To be clear, I would ask if I could safely assume that for the purposes of the problem, or more likely I would look at the tests around the problem and see if any of them included obviously non-Latin-1 chars and thus cue me that they need special handling. (If I can't see the tests while I'm writing the code that's supposed to pass them, you'd better believe I will ask about that!)

I wouldn't necessarily ding a candidate for not asking, though. For one thing, this is all pretty basic info, and would certainly be available in "real life" - so if it isn't available in the interview, then the interview isn't a sufficiently accurate representation to produce a clean signal.

For another, and for the same reason, the perceived power differential between panelist and candidate has to be taken into account. You're not going to get a clean signal if you bring your ego into the session, or otherwise give the candidate cause to feel more intimidation than the context naturally inspires.

Some folks are more confident than others, sure - but it's a technical interview, and confidence isn't really of interest beyond the baseline of not seeing a candidate dissolve into a puddle of flop sweat. (And, in any case, if that does happen then it's at least as much my fault as anyone's, because if I'm not able to help people be comfortable enough to even function on my team or in my engineering org, then I'm not doing my job right!)

So yeah, granted, I haven't interviewed with you and I don't know any details beyond what you've chosen to describe, so take this advice for whatever you find it to be worth. But, especially in a language like Java which I gather makes it more necessary to account for utf8 weirdness in strings than the languages I more commonly work with, I definitely think you'll see a significant improvement with just that one simple change of not using strings where you really don't need to in the first place. That might not be the only thing that needs attention - I suspect your pipeline may need some love, too - but I'm fairly confident it's an excellent place to start.

(For what it's worth, my experience with tech interviews extends well beyond the candidate's role; I've been participating in them as a panelist for a good few years now, and lately, by request, have been doubling up my sessions as mentoring/shadowing opportunities for other engineers and EMs who want to improve their own panelist skills. Granted, I've approached this discussion largely from the candidate's perspective - but then too, I'd argue very firmly that if you're not considering how your interviews might go from the candidate's perspective, then that's something you need to work on, too.)

Re:Lessons learned from the recent job hunt by lokeg on Sunday May 08, 2022 @08:24PM (#31309280)
> It's trivial in quadratic time too, of course, although I would expect a candidate for a senior role to be able at least to find the linear solution, if not to start there outright.

I would not call this trivial. The code in your post is incorrect. For example, it cannot find "ababc" within "abababc", since after the first mismatch we skip too much of the haystack.

The real solution to this is Knuth-Morris-Pratt, where we must precompute for every index in the needle the longest needle prefix that fits before it. I would not expect your average interviewee to derive or implement this.

An easier linear time solution (in my opinion) is rolling polynomial hashing. But if you actually expect solutions in an interview you should settle for the naive quadratic algorithm.

Re:Lessons learned from the recent job hunt by foobarian on Sunday May 08, 2022 @05:53PM (#31308457)
Speaking for our org, but it's because most business logic in our backends is about the same level or more complicated than String.contains.
Re:Lessons learned from the recent job hunt by throwanem on Sunday May 08, 2022 @06:13PM (#31308570)
Is it, though? I think real cases might frequently be less complicated, in Java at least. As is evident from the candidate experiences that the original commenter describes, there's a lot more complexity in strings than is immediately obvious.

I agree with 'Gunax that that's likely to be tripping people up - as I mentioned in the comment to which you're replying, albeit in a somewhat recent edit, this has not nothing to do with why our own similar interview problems don't revolve around any operation on strings.

Re:Lessons learned from the recent job hunt by foobarian on Sunday May 08, 2022 @08:58PM (#31309430)
> Is it, though?

You have no idea :-) Oh how I wish it were not the case

Re:Lessons learned from the recent job hunt by majormajor on Sunday May 08, 2022 @04:43PM (#31307971)
> I've found that far less people in software understand and are curious about algorithms than there were 15 years ago, despite the fact that almost everyone studies them now for interviews.

I would argue people who prep with LeetCode aren't studying algorithms at all, they're doing something much closer to memorizing.

I've seen people who I assume did a bunch of cramming like that because they'll be like "oh this is [xyz]" and throw out a solution in a hurry, and then I ask them to modify it in a non-standard way, and it's almost as if the idea that an off-the-shelf regurgitation of the "normal" solution for a problem not being able to handle a modified scenario is something they've never thought about.

Like "oh this is a search problem" -> "what if [something that essentially boils down to the graph potentially having cycles]?" -> [head expodes instead of thinking about, say, tracking what nodes have already been seen]

Re:Lessons learned from the recent job hunt by closeparen on Sunday May 08, 2022 @08:53PM (#31309401)
Well first a lot of software we work on now isn’t pushing performance limits. The long poles in these development projects are requirements and domain understanding.

The software that does push technical limits is likely to push IO, storage, and reliability related limits rather than compute. Distributed systems and big data are topics with a lot of interest in the last 15 years!

We call them “computers” and algorithms are very important for computation, but many commercial applications these days actually use them in their capacity as telecommunications devices and data storage and retrieval systems, with the actual “computing” part being much less ambitious.

Re:Lessons learned from the recent job hunt by sideshowb on Sunday May 08, 2022 @02:10PM (#31306510)
> I've found that far less people in software understand and are curious about algorithms than there were 15 years ago

Maybe because so many SW job descriptions these days seem to consist of plugging library into framework, and anyone interested in algorithms would be bored?

Not saying that's what you're recruiting for, but the industry has expanded massively while I'm guessing the number of algorithm heavy jobs has stayed roughly constant.

Re:Lessons learned from the recent job hunt by zahllos on Sunday May 08, 2022 @02:38PM (#31306799)
My favourite approach to big-O questions to to reply O(exp^n) to everything. When asked I point out that whatever it is, exp^n surely bounds it. This'll go either two ways. The interviewer will reflect on whether it is a least upper bound or not (and whether my statement is right) which makes for an interesting discussion about the other types of Landau notation. Or they'll get angry.

Ultimately I'm not convinced based on my own personal experience that many of the people asking the question truly understand either. I see it in a somewhat negative light because I feel it is essentially a cargo culted interview technique - recite a few 0()s, yeah we all did CS degrees, great (or not). If you actually try to get into the weeds...

I also don't think understanding big O notation is a great predictor of success of a software engineer. As well to ask if the series 1/n converges versus 1/n^2. What I'd rather see is that they can actually implement a solution. Take an ORM for example - a junior candidate knows how to use it and maybe how to debug it. A senior candidate might know that ORMs often emit very poorly optimised SQL and have some ideas on how to fix it. Example picked arbitrarily, ORMs aren't even my area.

Even in my actual area of specialty the number of industry programmers who understand say what an elliptic curve with complex multiplication actually is, or even undergrad group theory, is quite limited. And they don't need to - I mean it is ideal if they do, but you can still implement ecc without much theoretical knowledge. There's also a bunch of "not academic" knowledge on various implementation techniques that academics might not know or care about.

Brings me back to my ORM point. I'd much rather the person understands how the tools might fit together and more importantly learns any gaps or asks questions and identifies performance issues in the whole.

That's not to say that time and space bounds don't matter. They do. But 99% of my use of this knowledge has been to answer interview questions.

Re:Lessons learned from the recent job hunt by dhd415 on Sunday May 08, 2022 @06:03PM (#31308516)
I suspect that lots of people ask for O(n) when they mean Θ(n) instead which specifies both an upper and lower bound. For example, specifying Θ(n^3) as the running time for a bubble sort would be incorrect whereas O(n^3) would be imprecise but not incorrect.
Re:Lessons learned from the recent job hunt by yobbo on Sunday May 08, 2022 @02:53PM (#31306962)
It is an upper bound for something, but not the upper bound for that algorithm.
Re:Lessons learned from the recent job hunt by zahllos on Sunday May 08, 2022 @04:52PM (#31308050)
Told you it drives people nuts.

So big-O implies that the runtime is "dominated" by the term in brackets, or put another way, if I say something is O(n^2) I'm stating that as n->infinity the runtime of the algorithm |R| <= c * n^2, where c is some constant.

This is still true of exp^n, since |R| <= cn^2 <= dexp^n. Or at least based on my analysis background I'd expect this behaviour. It is of course a little pointless to say the algorithm is O(exp^n), but that's a different issue. It is still an asymptotic upper bound.

I just checked my copy of Sipser. Example 7.3 on page 249 if you care. They give an example that f_1 is O(n^3) and state it is O(n^4) also, since n^4 is also an (asymptotic bound) bound.

But this is not the point. I have no formal computer science education at all (my background is mathematics, some logic if that counts, but I've never studied algorithms) but many interviewers insist on this one specific area of CS, and yet if you attempt to engage them on the meaning of the things then unless you are very lucky they will a) make some excuse about how they'd have to check, their degree is a while ago, or b) they're actually only reciting also.

I'm strongly of the view this is a massively cargo-culted interview question of questionable to no value for most software engineering jobs, given that interview time is very limited and there are many more important factors to evaluate.

Re:Lessons learned from the recent job hunt by randomtwiddler on Sunday May 08, 2022 @06:35PM (#31308693)
You seem to be missing the entire point of this kind of question. Yes, you are providing an upper bound. But as you yourself admit, your answer is useless. The point of big o is to put the lowest reasonable bound on an algorithm so they can be compared.

Your approach is basically interview trolling.

I don't use big o in interviews. That's more the domain of big data than the web slots I typically fill. I'm more interested in the depth of understanding they display in the techs they claim to know.

Re:Lessons learned from the recent job hunt by yobbo on Monday May 09, 2022 @03:51PM (#31318888)
The complexity bound of an algorithm is the worst possible complexity. It needs to be proven (by assuming the worst possible input data), and there exists only one provable bound for a particular algorithm.

Finding the complexity of an algorithm in school is an exercise for understanding algorithms, and gaining a "vocabulary" for talking about them. But, provable bounds don't correspond to practical bounds, since input data is almost never close to the worst-case scenario. It isn't really a practical skill.

Several algorithms have bad provable complexity but can perform well in practice, while algorithms with better provable complexity can perform worse on average input sets.

Re:Lessons learned from the recent job hunt by randomtwiddler on Sunday May 08, 2022 @06:44PM (#31308747)
A follow up. I'm more interested in a devs understanding of memory complexity than time complexity. Every single production performance issue I've seen out side of academic questions had been due to memory management issues.
Re:Lessons learned from the recent job hunt by ThrustVectoring on Sunday May 08, 2022 @05:00PM (#31308102)
Most of the value of understanding computational complexity of code is that you get a little voice saying "hey, this is probably going to cause issues on larger data sets" after writing something that passes tests and works on small pieces of trial data. A Chinese-Room understanding of O(n^2) vs O(n) and O(1) is plenty for noticing these, and may actually out-perform a more thorough understanding; what you want is to notice things going quadratic as you rush through a code review or slam out a feature, and that is almost entirely reliant on pure pattern recognition.
Re:Lessons learned from the recent job hunt by jtagen on Sunday May 08, 2022 @03:40PM (#31307452)
Upper bound? I thought it was a tight asymptotic lower bound.
Re:Lessons learned from the recent job hunt by LigmaYC on Sunday May 08, 2022 @10:40PM (#31309917)
It depends on if you want to scale the application, but I wouldn't choose the readable O(n^2) over the less readable O(n). I would just attempt to make the O(n) readable.