Live data from Hacker News

Many hard LeetCode problems are easy constraint problems

buttondown.com

51–60 of 551 posts

Re: Many hard LeetCode problems are easy constraint problems

#51

Earlier quoted context omitted.

If someone solves a leetcode hard with a constraint solver and you don't hire them, you are an idiot. Do you know how few people in this world even know what a constraint solver is, let alone how to correctly define the problem into one? I used a constraint solver to solve a homework problem once in my CS degree 3rd year. My god just writing the damn constraints was a huge cognitive load!

> If someone solves a leetcode hard with a constraint solver and you don't hire them, you are an idiot. I do hope you're exagerating here, but in case you aren't: this is an extremely simplistic view of what (software) engineers have to do, and thus what hiring managers should optimize for. I'd put "ability to work in a team" above "raw academic/reasoning ability" for the vast majority of engineering roles, any day.…

Hey I'm with you 100% about the idea of code-interviews/leetcode being a problem and the importance of culture-fit and ability to work on a team.

I should have said "if you deemed this a fail on the code interview, you are an idiot".

Re: Many hard LeetCode problems are easy constraint problems

#52
post #49

Long time ago, just for fun, I wrote a constraint solver problem that could figure out which high yield banks to put money into that were recommended on doctor of credit( https://www.doctorofcredit.com/high-interest-savings-to-get/ ) based on I played it for a while when interest rates were really low and used the thing for my own rainy day savings(I did get tired changing accounts all the time)

Repo?

Re: Many hard LeetCode problems are easy constraint problems

#53
I've always maintained that solving LeetCode is more about finding the hidden "trick" that makes the solution, if not easy, one that is already "solved" in the general sense. Look at the problem long enough and realize "oh that's a sliding window problem" or somesuch known solution, and do that.

Re: Many hard LeetCode problems are easy constraint problems

#54

Earlier quoted context omitted.

>The point of these problems is to test your cleverness. No it's just memorization of 12 or so specific patterns. The stakes are too high that virtually everyone going in will not be staking passing on their own inherent problem solving ability. LeetCode has been so thoroughly gamified that it has lost all utility of differentiability beyond willingness to prepare.

In defense of questions like this, “willingness to prepare” is a significant differentiator

It also means "I don't have money for food, and at this point I am desperate".

Re: Many hard LeetCode problems are easy constraint problems

#56

Earlier quoted context omitted.

>The point of these problems is to test your cleverness. No it's just memorization of 12 or so specific patterns. The stakes are too high that virtually everyone going in will not be staking passing on their own inherent problem solving ability. LeetCode has been so thoroughly gamified that it has lost all utility of differentiability beyond willingness to prepare.

Given this consider that LeetCode solving is rarely ever part of your work. So then, what are they selecting for with the habit?

Selecting for people like themselves.

Re: Many hard LeetCode problems are easy constraint problems

#57
post #45
post #5

Great insight. But this is sadly not applicable to interviews. > It's easy to do in O(n^2) time, or if you are clever, you can do it in O(n). Or you could be not clever at all and just write it as a constraint problem This nails it. The point of these problems is to test your cleverness. That's it. Presenting a not-clever solution of using constraint solvers shows that you have experience and your breadth of knowledg…

>The point of these problems is to test your cleverness. In my experience, interviewers love going to the Leetcode "Top Interview 150" list and using problems in the "Array String" category. I'm not a fan of these problems for the kind of jobs I've interviewed for (backend Python mostly), as they are almost always a "give me a O(n) runtime O(1) memory algorithm over this array" type challenge that really doesn't rese…

Majority Element is rated easy because it can be trivially solved with a hashmap in O(N) space and that's enough to pass the question on Leetcode. The O(1) space answer is probably more like a medium.

Re: Many hard LeetCode problems are easy constraint problems

#58
post #47

Earlier quoted context omitted.

That willingness to prepare doesn't reconcile with the realities of parenthood and all of the other responsibilities someone in their thirties may have. Consistently finding that time will be a huge ask, especially if you haven't worked on those problems in a while.

I mean, it would be illegal for them to state it outright, but most companies would prefer not to hire people with kids and other responsibilities. That's the whole reason there are specific discrimination laws for that.

LeetCode questions neatly solve the problem of not wanting to hire people who won't, or can't, spend hours of their free time doing things they hate for a goal they don't care about except to the extent that will feed and house them.

Re: Many hard LeetCode problems are easy constraint problems

#59
post #45
post #5

Great insight. But this is sadly not applicable to interviews. > It's easy to do in O(n^2) time, or if you are clever, you can do it in O(n). Or you could be not clever at all and just write it as a constraint problem This nails it. The point of these problems is to test your cleverness. That's it. Presenting a not-clever solution of using constraint solvers shows that you have experience and your breadth of knowledg…

>The point of these problems is to test your cleverness. In my experience, interviewers love going to the Leetcode "Top Interview 150" list and using problems in the "Array String" category. I'm not a fan of these problems for the kind of jobs I've interviewed for (backend Python mostly), as they are almost always a "give me a O(n) runtime O(1) memory algorithm over this array" type challenge that really doesn't rese…

Honestly in day to day programming I find data types & associated APIs are so so much more important than algorithms.

I would rather work with a flexible data type with suboptimal performance than a brittle data type that maybe squeezes out some extra performance.

Your example of in-place array mutation feels like a good example of such a thing. I feel like there should be a category of interviewing questions for "code-safety" not just performance.

Re: Many hard LeetCode problems are easy constraint problems

#60

Terrible question for an interview, and further highlights how our interviews are broken. Greedy algorithms tell you nearly nothing about the candidate's ability to code. What are you going to see? A single loop, some comparison and an equality. Nearly every single solution that can be solved with a greedy algorithm is largely a math problem disguised as programming. The entire question hinges on the candidate findin…

My best interview consisted of: -what projects have you done

-what tech you worked with and some questions about decisions

-debugging an issue they encountered before

-talking about interests and cultural fit

Instant green flag for me. Too bad that after receiving my offer covid happened and they had a hiring freeze.

Post reply on HN