News for hackers. Stuff that matters.
Re:Many Hard LeetCode Problems Are Easy Constraint Problems by _alternator_ on Friday September 12, 2025 @11:50AM (#45223465)
This. Literally every problem in NP can be cast as a constraint problem. The question of whether a solver is the right solution varies a lot depending on the application, and in an interview , it’s almost by definition not the right solution.

They can also be dreadfully slow (and typically are) compared to just a simple dynamic program.

Re:Many Hard LeetCode Problems Are Easy Constraint Problems by jojomodding on Friday September 12, 2025 @07:41PM (#45227954)
LeetCode problems typically are in P. The challenge is finding out why.
Re:Many Hard LeetCode Problems Are Easy Constraint Problems by mcmoor on Saturday September 13, 2025 @12:57AM (#45229422)
Yeah I think the trivial solution is always harder complexity and the main challenge is to lower it. Either from NP to P or from n*2 to n log n.
Re:Many Hard LeetCode Problems Are Easy Constraint Problems by zahlman on Saturday September 13, 2025 @11:01AM (#45232634)
> or from n*2 to n log n.

I guess you mean n^2 (or maybe n**2, if you're a fellow Pythonista). Many of these — especially the ones where the intended solution is characterized as using a "dynamic programming" technique — are reducible to n.