What is a 'brute force' solution?
Options
- A very fast and optimal solution to the problem
- Trying every option: correct but often slow (Correct option)
- A solution that needs special hardware to run
- An attack that exists only in security work
Answer
Trying every possibility directly: simple and correct, but often too slow for big inputs
Why
Brute force means the straightforward approach without clever tricks. Example: to find two numbers that add up to a target, check every pair with two nested loops (O(n²)).
In interviews, it is a good first step: state the brute force solution and its cost, then improve it (for example with a hash map in O(n)).
(In security, 'brute force' also names guessing passwords by trying many combinations.)
Remember
Brute force = try everything. Start there, then improve.