Top
Best
New

Posted by mpweiher 9/12/2025

Many hard LeetCode problems are easy constraint problems(buttondown.com)
679 points | 533 commentspage 5
swiftcoder 9/12/2025|
> Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.

Maybe it's my graphics programmer brain firing on all cylinders, but isn't this just a linear scan, maintaining a list of open rectangles?

mattmcal 9/12/2025||
Yes, you just need to maintain a stack of rectangles ordered from lowest to highest. You only ever have to push and pop the top of the stack, so the runtime is O(n).
scotty79 9/12/2025||
All problems cited are about testing if you can write if's, loops and recursion (or a stack/queue).

They aren't testing if you can write a solver. They are testing if you can use bricks that solvers are built out of because other software when it gets interesting is built out of the same stuff.

aeternum 9/12/2025||
You: Oh I know, I can use a constraint solver for this problem!

Interviewer: You can't use a constraint solver

taylodl 9/12/2025||
Use the right tool for the right job!
chipsrafferty 9/12/2025||
Would love to know how to actually assess the runtime complexity of constraint solvers like this.
BhavdeepSethi 9/12/2025||
It's insane how many of these new "AI" companies don't let you use AI or even your own IDE for coding interviews. And most questions from such companies are LC type problems so they know any AI tool can one shot it.
henry2023 9/12/2025||
I discourage it but I let them use it and then give them a specific problem that I know your average Claude 4 or GPT 5 will just not get it right.

Actually people perform worse in an interview using AI because they spend time trying to understand what the tool is proposing and then time to figure out why that doesn’t work.

BhavdeepSethi 9/12/2025||
My experience has been quite different. With Cursor/Claude code, I've ended up writing full fledge solutions (running cli/web servers with loggers and unit tests for each functionality). We're talking crawlers, cab booking service like uber, search engines with seed data. All within the hour.
IshKebab 9/12/2025||
Why is that insane? Seems logical to me.
BhavdeepSethi 9/12/2025||
Definitely not insane. Ironic is the correct term. The field is evolving, a lot of these companies talk about replacing outdated practices using AI. Asking software engineers to not use their own tools to solve problems falls under the same bucket.
whatever1 9/12/2025||
I tried a couple of times long time ago to solve them with cp/integer programming.

The interviewers were clueless so after 10 minutes of trying to explain to them I quit and fell back to just writing the freaking algo they were expecting to see.

phendrenad2 9/12/2025||
So LeetCode has fallen into the same trap as ProjectEuler (anyone remember that?)
Stevvo 9/13/2025||
The first example doesn't make a lot of sense, because coins only ever exist in "well-behaved" denominations. There is no currency with a nine unit coin.
treenode 9/13/2025|
It would have been worthwhile if this article had briefly touched upon how the constraint solvers are implemented, rather than avoiding this altogether
More comments...