Live data from Hacker News

Many hard LeetCode problems are easy constraint problems

buttondown.com

161–170 of 551 posts

Re: Many hard LeetCode problems are easy constraint problems

#161

Earlier quoted context omitted.

Its not really memorizing solutions. Yes you can get quite far by doing so but follow ups will trip people up. However if you have memorized it and can answer follow ups, I dont see a problem with Leetcode style problems. Problem solving is about pattern matching and the more patterns you know and can match against, the better your ability to solve problems. Its a learnable skill and better to pick it up now. Persona…

It is and isn't. I'd argue it's not memorizing exact solutions(think copy paste) but memorizing fastest algos to accomplish X. And some people might say well, you should know that anyways. The problem for me is, and I'm not speaking for every company of course, you never really use a lot of this stuff in most run of the mill jobs. So of course you forget it, then have to study again pre interview. Problem solving is…

The only part of memorizing fastest algorithm the vast majority needs is whatever name that goes by in your library. Generic reusable code works very well in almost any language for algorithms.

Even if you are an exception either you are writing the library meaning you write that algorithm once for the hundreds of other users, or the algorithm was written once (long ago) and you are just spending months with a profiler trying to squeeze out a few more CPU cycles of optimization.

There are more algorithms than anyone can memorize that are not in your library, but either it is good enough to use a similar one that already is your library, or you will build it once and once again it works so you never go back to it.

Which is to say memorizing how to implement an algorithm is a negative: it means you don't know how to write/use generic reusable code. This lack is costing your company hundreds of thousands of dollars.

Re: Many hard LeetCode problems are easy constraint problems

#162
- Constraint solvers? That's a nice concept, I heard about this once. However, for the purposes of the interview, let's just write some Python code, I wanna see your way of thinking...

(I think it's almost impossible to convince your interviewer into constraint solvers, while the concept itself is great)

Re: Many hard LeetCode problems are easy constraint problems

#163
Been working on a calendar scheduling app that uses a constraint solver to auto schedule events based on scheduling constraints (time of day preferences and requirements, recurrence rules), and track goal progress (are you slipping on your desired progress velocity? Get a notification). It’s also a meal planner: from a corpus of thousands of good, healthy recipes, schedule a meal plan that reuses ingredients nearing expiration, models your pantry, estimates grocery prices, meets your nutritional goals. Constraint solvers are black magic.

Re: Many hard LeetCode problems are easy constraint problems

#164

Earlier quoted context omitted.

Selecting for people like themselves.

I think this is one of the more true answers but can you be more specific? Like in race? Like in wealth? Like in defection willingness? Like in corruption? Asking for a friend who is regularly identified as among the most skilled but feels their career has been significantly derailed by this social phenomenon.

[deleted]

Re: Many hard LeetCode problems are easy constraint problems

#165

Interview: > We can solve this with a constraint solver Ok, using your favorite constraint solver, please write a solution for this. > [half an hour later] Ok, now how would you solve it if there was more than 100 data points? E.g. 10^12?

Maybe some preprocessing, maybe column generation, depends on the problem.

Re: Many hard LeetCode problems are easy constraint problems

#166
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…

[deleted]

Re: Many hard LeetCode problems are easy constraint problems

#167

My biggest problem with leetcode type questions is that you can't ask clarifying questions. My mind just doesn't work like most do, and leetcode to some extent seems to rely on people memorizing leetcode type answers. On a few, there's enough context that I can relate real understanding of the problem to, such as the coin example in the article... for others I've seen there's not enough there for me to "get" the ques…

The LC interviews are like testing people how fast they can run 100m after practice, while the real job is a slow arduous never ending jog with multiple detours and stops along the way.

But yeah that's the game you have to play now if you want the top $$$ at one of the SMEGMA companies.

I wrote (for example) my 2D game engine from scratch (3rd party libs excluded)

https://github.com/ensisoft/detonator

but would not be able to pass a LC type interview that requires multiple LC hard solutions and a couple of backflips on top. But that's fine, I've accepted that.

Re: Many hard LeetCode problems are easy constraint problems

#168

- Constraint solvers? That's a nice concept, I heard about this once. However, for the purposes of the interview, let's just write some Python code, I wanna see your way of thinking... (I think it's almost impossible to convince your interviewer into constraint solvers, while the concept itself is great)

import z3

Re: Many hard LeetCode problems are easy constraint problems

#169

My biggest problem with leetcode type questions is that you can't ask clarifying questions. My mind just doesn't work like most do, and leetcode to some extent seems to rely on people memorizing leetcode type answers. On a few, there's enough context that I can relate real understanding of the problem to, such as the coin example in the article... for others I've seen there's not enough there for me to "get" the ques…

Its not really memorizing solutions. Yes you can get quite far by doing so but follow ups will trip people up. However if you have memorized it and can answer follow ups, I dont see a problem with Leetcode style problems. Problem solving is about pattern matching and the more patterns you know and can match against, the better your ability to solve problems. Its a learnable skill and better to pick it up now. Persona…

Leetcode with no prep is a pretty decent coding skill test

The problem is that it is too amenable to prep

You can move your score like 2stddev with practice, which makes the test almost useless in many cases

On good tests, your score doesn't change much with practice, so the system is less vulnerable to Goodharting and people don't waste/spend a bunch of time gaming it

Post reply on HN