← Pointer Manipulation

Micro-Drill #86 — Remove element in-place

Pointer Manipulation Target: 10s

Write-pointer skips unwanted values. O(1) space removal pattern.

w = 0
for r in range(len(a)):
    if a[r] != val:
        a[w] = a[r]
        w += 1
# a[:w] has val removed

Type it from memory. Go.

Practice Problems

Related Coding Drills

← Micro #85 Micro #87 →