Live data from Hacker News

Leetcode Considered Harmful

fullcontextdevelopment.com

101–110 of 132 posts

Re: Leetcode Considered Harmful

#101

Whether Leetcode is necessary can be discussed but this person doesn't add anything to the discussion. Almost disconnected 7 paragraphs of text and the conclusion is FAANG and S & P 500 needs to find a way to assess without Leetcode. It clearly works for them so they continue doing it and able to grow their eng organisations to thousands of engineers. Any other solution to this problem wouldn't be without its trade o…

> If he really wants to contribute to tech industry he is more than welcome to found his own company and hire the way he wants, instead of saying "I don't like this FAANG find a new way!".

I don't think this is a very practical suggestion. FAANG are the winners and hold all the cash, which is why this is actually an issue. Asking someone to essentially try for a lottery ticket chance (in the best case) of repeating this success as a qualification for criticism is like telling people: "If you don't like America, you can get out"

Re: Leetcode Considered Harmful

#102

Earlier quoted context omitted.

If programming is an art, then the programmer should have an audition instead of an interview. Which is approximately what leetcode is.

Most arts have a portfolio, not an audition. Auditions are specific to the performing arts which programming is definitely not. Musically I'd equate programming more to composition, not performance as there is no audience.

Well architects designing large systems through and through are maybe like composers

Your run of the mill dev would be more like a studio musician hired to play a specific instrument in a specific genre.

Surely, he/she needs to be able to come up with lines/hooks/riffs/solos (when asked) and play part in the arrangement but composing from scratch and for multiple instruments would be rather out of scope.

While there's no direct audience for studio musicians (only the output matters) there are definitely performance expectations and the studio musicians are expected to be efficient.

Re: Leetcode Considered Harmful

#103
post #86

Does anyone have actual metrics about whether this stuff works or not? All I see is anecdote after anecdote in both directions. In god we trust, all others must bring data.

Googles interviews works according to their internal data. Google bans any questions that you can find on the internet though, including all questions you find on leetcode (they have people who check this, including the member only questions), they want to ensure that candidates only do problems they haven't seen before. Some accidents still happens, but since they have 5 interviews per candidate it is very unlikely…

That's what they say. I want to see the actual data.

I think part of the problem is that really in order to get proper data.... You have to actually hire the people who failed the interview.

So i actually doubt google has any good internal data. Not unless they hired a bunch of people who failed.

Re: Leetcode Considered Harmful

#104
post #32

Earlier quoted context omitted.

Well argued, but you didn't address the need for tests and/or certifications to prevent companies from being overwhelmed by a flood of unqualified candidates. A doctor, lawyer, public accountant, and, well, many types of engineers obtain public or private certifications. As a result, it is much, much, much easier for hiring companies to find and interview qualified candidates. I suppose, in the "old days" universitie…

Honestly, what we define as a flood of unqualified candidates is kind of ridiculous, nowadays it refers to anyone who didn't got to a top state school or top 1% equivalent. The reality is that there are too many qualified people at the lower end of the pipeline and this is because we don't hire enough people as it is for our current positions, why this happens is really simple. It's to save money. There's a reason wh…

> Honestly, companies just need to be comfortable with hiring someone with a credible degree and taking a chance on them.

I'd be all for it and I have seen some international non-profits hiring like that for junior roles.

But its a hard sell for googol and the likes who 1) have excess supply of qualified candidates 2) are so used to perpetuating the narrative of absolute exclusivity among their staff.

Re: Leetcode Considered Harmful

#105
post #27

Earlier quoted context omitted.

Leetcode: weeks or months spent grinding daily, adding easily up to 100s of hours Take home project: typically capped at 4 hours. Hmmm, this is a tough one...

Often enough someone gives a take home project that actually is not even close to be capped in the time range requested unless you already work on this project. Every such test is supposed to be calibrated. Leetcode... Is not.

Be that as it may, it will never even come close to the 100s of hours of leetcode grinding.

It's not even the same order of magnitude. Like I mentioned, it is common to spend months grinding leetcode. How can people rationalize this and prefer it to a closed scope assignment? I honestly don't get it.

Re: Leetcode Considered Harmful

#106
post #12

Happily employed and had no trouble with coding interviews myself. So my opinion isn’t from some personal angst about passing this bar: I found it easy. That said: I’m tired of the attitude that there is no effective alternative to this style of interview. You do know we hired people to do engineering jobs for many decades before the industry started cargo culting what they observed a handful of Silicon Valley mega-c…

"There are only two kinds of languages: the ones people complain about and the ones nobody uses." -Bjarne Stroustrup

And so it is with interviewing techniques. You say "[leetcode] interview processes are not the only way," which is of course true. But it is also true that all other interviewing techniques are also unpopular on HN and with programmers in general. Of course each programmer has one or more techniques that they prefer, but there is no single technique that has even simple majority support amongst engineers as a whole.

Let's review some common techniques and what HN would say. NB: not expressing my opinion on any of these, just compiling common complaints you can find in any HN thread about interviewing.

Leetcode problems: rewards rote memorization over real ingenuity, not relevant to job, high stress.

Take home problem: company not incentivized to respect candidate's time; bias towards candidates that are unemployed, not engaged at current job, or otherwise able to devote large amounts of time to the task; easier to outsource; basically asking candidates to "work for free"

Review of github profile, OS projects, blogs, etc...: bias against candidates that "have a life" and don't program 24/7.

Discussion of previous work: highly subjective, susceptible to frauds and/or exaggerators, prone to false positives (complaint usually phrased in a form like: "we did this at my last company and we hired a bunch of people who couldn't code.")

“I don't know what the l̶a̶n̶g̶u̶a̶g̶e̶ interview technique of the year 2̶0̶0̶0̶ 2030 will look like, but I know it will be c̶a̶l̶l̶e̶d̶ ̶F̶o̶r̶t̶r̶a̶n̶ unpopular on HN.

Re: Leetcode Considered Harmful

#107
This is no different than doctors who have to go through FRCS or EDAIC etc exams, these are very hard exams with very low pass percentage adding to the fact that you need to be a qualified MD when you give these exams. my wife is an MD and has been giving exams for the past 3 years and will be giving exams for atleast another 3 to 4 years and she studies with whatever little time she has after work. The exams she gives have little to nothing to do with the work she does. The real life medical work does not require you to be smart, most average people could do surgeries if they are trained. But getting in is the hard part. The exams there are not qualifying rounds but elimination rounds.

Medicine is an old field, and I think these leetcode style interviews are only the beginning for the computer science based industry, the bar is only going to get higher as years pass which I feel may not be a bad thing overall for the software field.

Re: Leetcode Considered Harmful

#108
post #77

I find Leetcode discussions strange. I recently changed jobs so I was preparing by doing some Leetcode problems. The actual problems I was asked during the interview process were very simple compared to what I expected. Interviewers even explicitly stated that they wanted to see how I think, and the solution didn't even have to compile. So in my experience the whole idea that «Leetcode is harmful» is overblown a litt…

Depends on the company. FAANG and unicorns will absolutely ask for it to compile (except Google which asks questions on Google Docs of all things), and they want the optimal solution almost right away and will penalize you for not getting such a solution.

Re: Leetcode Considered Harmful

#109
When interviewers give Leetcode problems, what kind of solutions are they looking for?

I've used Leetcode personally as a source of problems I can think about at a leisurely pace in my head. I like to have a few such things (algorithm or coding problems, math problems, physics problems, music theory problems, electronics problems) that I can use when I'm lying in bed but not quite falling asleep yet or stuck in a slow line somewhere to pass the time.

For the Leetcode problems I've used for that, usually from the "hard" or "medium" categories, it is almost always the case that I can easily and quickly come up with an algorithm that gives the answer and I could easily code but is O(n^2).

It is getting down to O(n log n) or O(n) that is difficult. (I'll give a couple of examples below for your amusement of problems where O(n^2) was easy but doing better took me weeks or months).

Are most interviewers satisfied with O(n^2) that produces the right answer or are they looking for something better than that?

Now for your amusement two problems that took me ages to get past O(n^2).

1. You are given an array of integers and are to find the smallest positive integer that is not in the array. For example given [1, 9, 4, 7, 2, 5] the answer is 3. Your answer should run in O(n) time and use constant extra space.

2. Find the longest palindrome in a string. No time or space constraints are specified.

For the first missing positive integer problem without the time and space constraints the answer that quickly comes to mind is to sort the array (O(n log n)) then scan for the first i such that the element at the i'th position is not i ((O(n)).

What really threw me was the constant space requirement. I had always assumed the inputs were constant in Leetcode problems and could and so could not think of a way to do this without using O(n) space.

I even ended up spending a while trying to prove that it could not be done in constant space hoping that when I could not prove that seeing why I could not would point me toward what I was missing. But I was able to sort of convince myself that a Turing machine could not do it in constant space--"sort of convince" because I'm rusty enough with Turing machines I could not be sure I was missing something.

It turns out that inputs aren't constant in Leetcode problems. You are allowed to modify input arrays. It was then not too hard to figure out the O(n) time and constant extra space solution.

For the palindrome problem an O(n^2) is quite straightforward. But I've got a couple of other approaches that seem faster.

Let's call the two halves of a palindrome its "arms". So an even palindrome consists of two arms that are mirror images next to each other and an odd palindrome consists of two mirror image arms that are separated by one character.

If you have an even palindrome with arms of length n, and you want to check for an odd palindrome one over to the that is longer than the even palindrome, you can move the right arm over by one and check that it is still a mirror of the left. If it is you have found a longer odd palindrome.

It the shifted arm does not match, you can then shift the left arm over and check for a match. If they match you have an even palindrome of the same length. You can then check to see if the arms can be extended while still matching.

By inching the arms across the string this way, extending them when possible, you can sweep the string finding the longest polynomial. If verifying that the arms are mirror images was O(1) this inching approach would be O(n). But comparing the arms the most obvious way os O(L) where L is the length of the arm, which would be 1/2 the length of the longest palindrome found so far, which would be O(n), so the inching approach with the simplest arm matching is O(n^2).

But can we do better? What if we maintain for each arm some kind of hash. We can compare the hashes of the arms and only if the hashes match do we need to then do a character by character check that the arms really match. But this doesn't seem to buy us anything because hashes are O(L).

But maybe we can take advantage of the fact that we are moving the arms one character at a time through the string. We need a hash H that given a H(S) for some string S allows as to compute H(S') where S' is S with a single deletion from one end and a single addition at the other end. For example, our hash might simply be the sum of all the characters in the string. Computing that for an arm after sliding it one addition and one subtraction.

I'd rather have a hash where strings that are just permutations of each other hash differently, so spent a while on that. I came up with something that seemed pretty good, then realized that rsync has such a hash and I should use grab that. It turns out though that the one I came up with is the one rsync uses.

I'm now stuck trying to figure out the run time of this. In most cases I think it will be somewhere between O(n) and O(n^2). Where depends on how often the hash gives false positives on arm matching.

The other approach I'm playing with is completely different. Suppose we scan the string and build a frequency table of all the characters. This is O(n). Now look at the least common character and note the constraints that it puts on the possible positions of long palindromes.

For example suppose the string is 1000 characters long and it only has 3 'X's, which are at positions 10, 200, and 700. We can immediately deduce that if the first X is part of a palindrome that does not include the second X it is an odd palindrome of at most length 19. If the first two X's are part of a palindrome it must be odd and up to length 219. We can make similar deductions for the rest of the cases, and we can rule out any palindromes containing all three X's.

We can check each of those cases to find the longest palindrome involving X. That leaves us with the string partitioned into 4 sections where we then need to check for palindromes larger than the largest X-containing palindrome.

We could then do a similar thing with the lest frequent character in each of those regions, and so on.

Or maybe better is to start with the two least frequent characters and consider their distribution in the string together.

In general the idea here is that the distribution of any particular character in the string imposes constraints on where long palindromes might be and maybe we can build up a set of such constraints to cut the number of palindrome checks we have to do sufficiently to get an efficient algorithm.

That's about as far as I've gotten with this approach. I feel there is probably something there but it might take someone way smarter than me to find it.

Re: Leetcode Considered Harmful

#110
post #77

I find Leetcode discussions strange. I recently changed jobs so I was preparing by doing some Leetcode problems. The actual problems I was asked during the interview process were very simple compared to what I expected. Interviewers even explicitly stated that they wanted to see how I think, and the solution didn't even have to compile. So in my experience the whole idea that «Leetcode is harmful» is overblown a litt…

If I used Leetcode to interview someone I wouldn't even ask them to code a solution.

I'd show them a few problems that I thoroughly understand, ask them to pick two or three of them, and ask them for their thoughts on how to approach them. It would just be a discussion with no need to touch a computer. A whiteboard and scratch paper would be available if they wanted to use them.

I'd provide enough input to make sure the discussion moves along to figuring out a solution, but would try to let them take the lead only providing enough myself to make sure we make progress.

If I ended up providing most of the solution that would be fine. The most important part of the interview comes later.

Then what we'd do is look at the official answer and talk about it, seeing where it matches what we expected and where it does things differently, and maybe talk about whether those differences make it better than what we came up with.

Finally, and this is the most important part, we'd go to the Leetcode discussion for the problem.

In the discussion people post all kinds of solutions and those have all kinds of errors. Some are just flat out wrong. Some are mostly right but miss common edge cases (edge cases I would have made sure the interviewee and I talked about earlier). Some miss somewhat ridiculous edge cases such as failing if an input array is so large that all positive integers in the language they are using are valid array indexes. Some always give the right answer but don't meet the specified time or space constraints.

We'd do code reviews on some of those, again with me trying to just provide enough input to keep things moving along.

Post reply on HN