3 ms·
Without using any math terms at all: Suppose you've got a list of numbers: 5, 11, 26, 13, 215, 55, 68, 99, 3, 7, 41 And I ask: "Do any of these numbers t
by simonsarris 11y ago
Without using any math terms at all:
Suppose you've got a list of numbers:
5, 11, 26, 13, 215, 55, 68, 99, 3, 7, 41
And I ask: "Do any of these numbers together add up to 126?
You might have to try every combination of numbers to get an answer. It can be very slow to do, trying every single combination (imagine a list with thousands of numbers, and a very long goal number). Maybe there are no combinations!
But once you have an answer:
11 + 13 + 99 + 3 = 126
It is very easy to verify that the provided answer is correct (are all those numbers in my list? Yes, verified!)
Compare that problem to this one: Is this list of numbers in ascending order?
4, 7, 11, 22, 6, 35
The answer is "No, because of the 6." Finding the answer is much faster because you can do it on one read-through of the list. You aren't checking a huge number of potential combinations or anything.
The first problem is in the class of problems called NP-Hard.
Oof. Getting lengthy so I'll shush here. Hope that gives you an intuitive feel for it.