← Two Pointers

Pattern Recognition Drill

#32 — Merge two sorted arrays

Easy Sorting

The Problem

Merge two sorted arrays into one sorted array.

What approach would you use?

Think about it before scrolling down.

Key Signals

Two Pointers

One pointer per array, always pick the smaller front element. O(n+m).

Common Trap

Concatenate + re-sort is O((n+m) log(n+m)). Merge is O(n+m) — exploit the sorted property.

← #31 #33 →