Your concept feed

33 ideas

A few small steps. No rush.

Follow the connections in this topic

Let’s picture it

Try every pair first.

1
2
4
7

In a sorted row [1,2,4,7], seek a pair totaling 9. Checking every pair repeats work.

Swipe when you’re ready
One little change

Look at both ends.

1 ↑
7 ↑
sum 8

1 + 7 is too small. Moving the right pointer left only makes the sum smaller, so move the left pointer right.

Same idea. One more small step.
Now it has a name

Discard with a reason.

too small → left
too large → right
equal ✓

Now 2 + 7 = 9. Each move removes an entire family of impossible pairs, so both pointers move only forward overall.

Want to try a tiny question?
No pressure. Just try it.

When the sum is too small, which pointer can safely move?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Let’s start with three stops.

🏠 Home
🌳 Park
☕ Café

Home. Then the park. Then the café. Just a few things in a row.

1 / 3
A familiar idea

Width and height both matter.

width
shorter wall
area

Lines of heights [1,8,6,2,5,4,8,3,7] form containers. Two chosen lines hold width times the shorter height.

Swipe when you’re ready
One new wrinkle

Start with maximum width.

left: 1
right: 7
area: 8

The outer lines give width 8 and height 1. The shorter left wall limits the water.

Same idea. One more small step.
Try a tiny example

Move only the limiting wall.

shorter moves
taller stays

Moving the taller wall inward loses width while height stays capped by 1. Move the shorter wall and hope for a taller limit.

Same idea. One more small step.
Notice what matters

Keep the best seen.

8
width 7
7 → 49

The best pair uses heights 8 and 7 with width 7, giving 49. The proof discards pairs, not just guesses.

Want to try a tiny question?
No pressure. Just try it.

Why keep the taller wall when shrinking the width?

You can also keep scrolling
1 / 5
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Try every pair first.

1
2
4
7

In a sorted row [1,2,4,7], seek a pair totaling 9. Checking every pair repeats work.

1 / 3
Let’s picture it

Order can expose structure.

4
1
3
1

Unsorted values [4,1,3,1] hide equal neighbors and make smallest-first processing awkward.

Swipe when you’re ready
One little change

Sort once, scan simply.

1
1
3
4

After sorting: [1,1,3,4]. Duplicates touch, boundaries become visible, and two pointers become possible.

Same idea. One more small step.
Now it has a name

Account for the price.

sort cost
simpler scan
reuse order

Comparison sorting usually costs O(n log n). It is worthwhile only when the simpler scan or repeated queries repay that cost.

Want to try a tiny question?
No pressure. Just try it.

Does sorting preserve original positions automatically?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Let’s start with three stops.

🏠 Home
🌳 Park
☕ Café

Home. Then the park. Then the café. Just a few things in a row.

1 / 3
Let’s picture it

Split until the promise is tiny.

4,1
3,2

A list of one item is already sorted. Split [4,1,3,2] into smaller lists until reaching that base case.

Swipe when you’re ready
One little change

Merge two sorted answers.

1,4
2,3
1,2,3,4

From [1,4] and [2,3], repeatedly take the smaller front item. Neither front can be beaten by anything behind it.

Same idea. One more small step.
Now it has a name

The levels have equal total work.

n per level
log n levels

Each merge level touches n items, and there are logarithmically many levels.

Want to try a tiny question?
No pressure. Just try it.

Why is the smaller front safe to output next?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Order can expose structure.

4
1
3
1

Unsorted values [4,1,3,1] hide equal neighbors and make smallest-first processing awkward.

1 / 3
Let’s picture it

Choose a pivot value.

4
1
3 pivot
2

For [4,1,3,2], choose 3. We want smaller values before it and larger values after it.

Swipe when you’re ready
One little change

Grow a finished left region.

≤ pivot done
unknown
pivot

Scan the range. Whenever a value is at most the pivot, swap it beside the completed smaller region.

Same idea. One more small step.
Now it has a name

Only recurse where order is unknown.

smaller
pivot fixed
larger

After partitioning, the pivot is in its final position. Sort the two sides; never sort the pivot again.

Want to try a tiny question?
No pressure. Just try it.

Does a fixed bad pivot keep O(n log n) time?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Order can expose structure.

4
1
3
1

Unsorted values [4,1,3,1] hide equal neighbors and make smallest-first processing awkward.

1 / 3
Let’s picture it

We need one rank, not full order.

3, 2, 1
5, 6, 4

To find the second largest in [3,2,1,5,6,4], fully sorting every relationship is extra work.

Swipe when you’re ready
One little change

Partition gives a final rank.

smaller
pivot rank
larger

Place a pivot so smaller values lie left and larger values lie right. Its index is final even though each side remains unsorted.

Same idea. One more small step.
Now it has a name

Follow only the useful side.

discard
target side

If the target rank lies right of the pivot, discard the entire left side and pivot.

Want to try a tiny question?
No pressure. Just try it.

After the pivot lands on the target rank, must its sides be sorted?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Choose a pivot value.

4
1
3 pivot
2

For [4,1,3,2], choose 3. We want smaller values before it and larger values after it.

1 / 3
Let’s picture it

Comparisons are not the only information.

0:1
1:1
2:2

Values [2,0,2,1] come from the tiny known range 0..2. Count each value directly.

Swipe when you’re ready
One little change

Counts rebuild sorted order.

0
1
2
2

Emit zero once, one once, and two twice. No pairwise comparisons are needed.

Same idea. One more small step.
Now it has a name

Large keys need digits or another plan.

count range
stable digit passes

Radix sort groups by one digit at a time using a stable inner sort. Tiny range and fixed-width digits are different guarantees.

Want to try a tiny question?
No pressure. Just try it.

Is counting sort efficient when keys range from 0 to one trillion?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Order can expose structure.

4
1
3
1

Unsorted values [4,1,3,1] hide equal neighbors and make smallest-first processing awkward.

1 / 3
Let’s picture it

Search for the first yes.

no
no
no
yes
yes

In [no,no,no,yes,yes], the answer is the first yes, not merely any yes.

Swipe when you’re ready
One little change

Keep a half-open range.

left
middle
right excluded

Maintain [left,right) containing the boundary. Test middle; yes keeps the left half, no discards through middle.

Same idea. One more small step.
Now it has a name

Stop when no uncertainty remains.

left = right
boundary

When left equals right, the range is empty and that position is the first true answer.

Want to try a tiny question?
No pressure. Just try it.

If middle is true, may we discard middle too?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Find 8 in a sorted row.

2
4
6
8
10

Start with 2, 4, 6, 8, 10. Look at the middle: 6.

1 / 3
Let’s picture it

A sorted row was rotated.

4,5,6
7
0,1,2

[4,5,6,7,0,1,2] has one break. We seek 0 without scanning every value.

Swipe when you’re ready
One little change

One half is still sorted.

4..7 sorted
0 not there

At middle 7, the left half 4..7 is ordered. Since 0 is not inside its value range, discard that half.

Same idea. One more small step.
Now it has a name

Use order before choosing a side.

which half sorted?
target inside?

At every step, identify a sorted half, then ask whether the target lies inside its bounds.

Want to try a tiny question?
No pressure. Just try it.

Can duplicate values hide which half is sorted?

You can also keep scrolling
1 / 4
Arrays, search & sorting

This idea builds on these smaller ones. Pick any to revisit it here.

Search for the first yes.

no
no
no
yes
yes

In [no,no,no,yes,yes], the answer is the first yes, not merely any yes.

1 / 3
Let’s picture it

Intervals hide overlap when shuffled.

8..10
1..3
2..6

[8,10], [1,3], [2,6] are hard to combine in input order.

Swipe when you’re ready
One little change

Sort by starting point.

1..3
2..6
1..6

Now [1,3] and [2,6] touch in the scan. Because 2 ≤ 3, extend the current end to 6.

Same idea. One more small step.
Now it has a name

A gap closes one group.

1..6
gap
8..10

[8,10] starts after 6, so emit [1,6] and begin a new current interval.

Want to try a tiny question?
No pressure. Just try it.

What single value summarizes the merged group while scanning?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Order can expose structure.

4
1
3
1

Unsorted values [4,1,3,1] hide equal neighbors and make smallest-first processing awkward.

1 / 3
Let’s picture it

Meetings change a running count.

1: +1
4: −1

Meeting [1,4) adds one active room at 1 and removes one at 4.

Swipe when you’re ready
One little change

Sort all changes by position.

1:+1
2:+1
3:−1
4:−1

For [1,4) and [2,3), events are +1, +1, −1, −1. The largest running total is two.

Same idea. One more small step.
Now it has a name

Tie order encodes endpoint meaning.

end first
start second

For half-open meetings, an ending at time 3 frees a room before another meeting beginning at 3 uses one.

Want to try a tiny question?
No pressure. Just try it.

Why must equal-position events have a defined order?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Order can expose structure.

4
1
3
1

Unsorted values [4,1,3,1] hide equal neighbors and make smallest-first processing awkward.

1 / 3
Let’s picture it

Update a whole range cheaply.

0
+3
?
?

Add 3 to positions 1 through 3. Instead of touching three cells, record +3 where the effect begins.

Swipe when you’re ready
One little change

Cancel just after the range.

start +3
carry
end+1 −3

Record −3 at position 4. A running sum carries the update across positions 1,2,3 and removes it afterward.

Same idea. One more small step.
Now it has a name

Many updates combine before one scan.

two marks per update
one final scan

Each range contributes two boundary changes. One prefix sum reconstructs every final value.

Want to try a tiny question?
No pressure. Just try it.

Does a difference array answer arbitrary online point queries immediately?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

A window meets a negative number.

2
−1
1

Find stretches totaling 2 in [2, −1, 1]. Adding −1 shrinks the sum, so the usual window direction is no longer reliable.

1 / 5
Let’s picture it

A running stretch may become harmful.

4
−7
5

For [4,−7,5], carrying 4−7 into the last value gives 2. Restarting at 5 is better.

Swipe when you’re ready
One little change

One state ends exactly here.

start here
extend previous

At each position, compare starting fresh with extending the best stretch that ended one position earlier.

Same idea. One more small step.
Now it has a name

Keep a separate global best.

ending here
best anywhere

The best ending here may fall, while the best seen anywhere must never be forgotten.

Want to try a tiny question?
No pressure. Just try it.

For an all-negative list, may the answer be zero?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Same door. One small difference.

You + key
Locked door

You have a key. Your friend doesn’t. The door is the same, but your next move isn’t.

1 / 3
Let’s picture it

Only three values exist.

2,0
2,1
1,0

Arrange [2,0,2,1,1,0] so every 0 precedes every 1, which precedes every 2.

Swipe when you’re ready
One little change

Name four regions.

0s
1s
unknown
2s

Keep completed zeros, completed ones, unknown values, and completed twos. Three pointers mark their boundaries.

Same idea. One more small step.
Now it has a name

Inspect only the unknown front.

0 → left
1 → next
2 → right

A 0 moves left, a 1 stays, and a 2 swaps right. After swapping right, inspect the incoming value before advancing.

Want to try a tiny question?
No pressure. Just try it.

After swapping a 2 with the unknown right edge, may the scan always advance?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Find 8 in a sorted row.

2
4
6
8
10

Start with 2, 4, 6, 8, 10. Look at the middle: 6.

1 / 3
Let’s picture it

Only a small value range can answer.

useful: 1..n
answer ≤ n+1

With n items, the first missing positive lies between 1 and n+1. Values outside 1..n cannot fill those n positions.

Swipe when you’re ready
One little change

Give each useful value a home.

1 → index 0
2 → index 1
3 → index 2

Value x belongs at index x−1. Swap values toward their homes while the current useful value is misplaced.

Same idea. One more small step.
Now it has a name

Scan for the first mismatch.

index i
expected i+1

After placement, the first index i not holding i+1 reveals the missing positive.

Want to try a tiny question?
No pressure. Just try it.

Why stop swapping when the destination already holds the same value?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Only three values exist.

2,0
2,1
1,0

Arrange [2,0,2,1,1,0] so every 0 precedes every 1, which precedes every 2.

1 / 3
Let’s picture it

Different keys can share one bucket.

key A → 1
key B → 1

With three buckets, keys hashing to 1 must coexist. A hash is not a unique identity.

Swipe when you’re ready
One little change

Store and compare real keys.

hash → bucket
equality → key

Separate chaining keeps a small list per bucket. Hash chooses the list; equality finds the exact entry.

Same idea. One more small step.
Now it has a name

Resize before chains grow too long.

load grows
new table
rehash

When load factor rises, allocate more buckets and rehash every key because bucket positions depend on capacity.

Want to try a tiny question?
No pressure. Just try it.

May a hash match replace an equality check?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Let’s remember a little more.

Park
5 minutes

The park is five minutes away. Write that beside its name.

1 / 3
Let’s picture it

A maximum expires as the window moves.

1,3,−1
3,−1,−3
−1,−3,5

For [1,3,−1,−3,5] with width 3, the first window maximum is 3. Later, 3 leaves.

Swipe when you’re ready
One little change

Keep useful candidates in a deque.

front = max
decreasing values

Remove smaller values from the back before adding a new index. They expire no later and cannot become maximum.

Same idea. One more small step.
Now it has a name

Remove expired indices from the front.

index
window left
expire

Indices reveal whether the current maximum lies before the new window’s left boundary.

Want to try a tiny question?
No pressure. Just try it.

Why store indices instead of only values?

You can also keep scrolling
1 / 4
Arrays, search & sorting

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Who is still waiting for warmth?

73
71
74

Temperatures are 73, 71, 74. The first two days have not yet seen a warmer day.

1 / 5
You've reached the end of these ideas.Try them without the labels