🌱 DSA (Beginner) · Core Patterns · cozy lesson
Two Pointers
12 min · 1 min read · no scary math, promise
🤖
You’ve got this. Read a little, play a little — I’ll wait. No rush.
def two_sum_sorted(a, t):
l, r = 0, len(a)-1
while l < r:
s = a[l]+a[r]
if s == t: return [l, r]
if s < t: l += 1
else: r -= 1
Same-direction: merge sorted, remove dups. Opposite: 3Sum (fix one + two pointers).
💛 Enjoying? Try 5 playful quizzes or watch it move.
Check your understanding
Correct answers earn XP (once each).
1. Two Sum II sorted → ?
2. Container With Most Water?
My notes (saved in this browser)
Select text above → Save selection, or write your own. AlgoMaster-style notebook, local-first for MVP.
No notes yet. Your highlights will live here.
Finished reading? Seal it with a tick ✅
The checkbox in the explorer turns green too — same progress.