← Back to the arrays page

Sorted Array

Order unlocks logarithmic search and linear merging — most classic array algorithms assume or create sortedness.

What to know

  • Binary search needs random access — it is an array algorithm, not a list algorithm.
  • Two pointers from both ends solve pair-sum problems without extra memory.
  • Merging two sorted arrays is the heart of merge sort and external sorting.

In the wild: Database indexes, sorted ID lists in search engines, time-series query windows.

Algorithms to reach for

Binary search

O(log n)

Find element or insertion point

Two pointers (opposite ends)

O(n)

Two-sum sorted, container with most water

Merge of sorted arrays

O(n + m)

Combine sorted runs stably

Practice problems — with full guides

Each problem has its own page: progressive hints, how to approach it, and the full solution.