Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Visualizer › Searching

Linear Search

Checks every element from left to right until it finds the target or reaches the end.

How it works

Complexity

Code (Python)

def linear_search(a, target):
    for i, x in enumerate(a):
        if x == target:
            return i
    return -1

Practise: Arrays problems