Repaso
Español
Algorithms & DSFoundationsALG-54

What is a 'brute force' solution?

Options

  1. A very fast and optimal solution to the problem
  2. Trying every option: correct but often slow (Correct option)
  3. A solution that needs special hardware to run
  4. 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.

Key terms

Practice this question in Repaso