Get the latest tech news

Many hard LeetCode problems are easy constraint problems


Use the right tool for the job.

Lots of similar interview questions are this kind of mathematical optimization problem, where we have to find the maximum or minimum of a function corresponding to constraints. The "proper" solution is a tricky thing involving tracking lots of bookkeeping states, which you can completely bypass by expressing it as constraints: Constraint solvers runtimes are unpredictable and almost always than an ideal bespoke algorithm because they are more expressive, in what I refer to as the capability/tractability tradeoff.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of leetcode problems

leetcode problems