Search⌘ K

Brute Force

Explore the brute force algorithmic paradigm to solve coding problems by exhaustively checking all possibilities. This lesson helps you understand linear search and the pros and cons of the brute force approach, equipping you to recognize its role and limitations in coding interviews and when to seek more efficient solutions.

Brute force method

Let’s start off our discussion on algorithms with the most straightforward and exhaustive option—the brute force approach to solving a problem. This method requires us to go through all the possibilities to find a solution to the problem we want to solve. For instance, if we have a list of integers and we want to find the minimum, maximum, or a certain element in that list, the brute force approach requires us to go through all the elements to find that specific element.

Let’s look at an example that might help you visualize this technique.

Example: Linear search

Linear/sequential search is a method for finding a target value within a given list. It sequentially checks each element of the list for the target value until a match is found or all ...