LearnThatStack Ace your next interview
Computer Science Fundamentals

Arrays, Strings & Hash Tables.

Start free Change topic Change

Practise Arrays, Strings & Hash Tables one question at a time. Answer out loud or in writing, get graded, and see exactly what you missed.

Try one question

What is an array and how is it stored in memory?

The answer

An array is a fixed sequence of elements of the same type, laid out back to back in one contiguous block of memory. Because every element takes the same number of bytes, the array only needs to remember its starting address and its length.

The values sit next to each other in order, with no gaps and no pointers linking them. A five-element integer array is just five integers packed tightly, one after another.

Reading nearby elements is fast, since the CPU pulls in whole cache lines at once. The cost is rigidity. The block is one piece, so you cannot cheaply grow it in place when neighboring memory is already taken.

Example · what grading looks like
What is the difference between a static array and a dynamic array?

“A static array has a fixed size that you pick when you create it, and it can't change after that. A dynamic array, like a Python list or a Java ArrayList, grows as you add elements. Underneath it's still one contiguous block of memory, so when it runs out of room it grabs a bigger block and moves the elements over. Looking something up by index is O(1) in both. So I'd use a static array when I know the size up front, and a dynamic one when I don't.”

Knew it

Covers fixed vs growable size, contiguous storage with reallocation on overflow, O(1) lookup, and when to use each. Doesn't mention that static arrays have zero resizing overhead, which is why you'd pick one when the count is known.

Missed: Doesn't mention that a static array has zero overhead when the count is known ahead of time


Get your own answers graded

Sign up free. Your account comes with 50 credits for grading, and it remembers what you missed.

What it covers

All 85 questions

Each on its own page

Array storage and basic costs

How arrays sit in contiguous memory, why indexing is O(1) while search and middle inserts are O(n), and when arrays beat linked lists.

9 questions

  1. What is an array and how is it stored in memory?
  2. Why is accessing an array element by its index O(1)?
  3. Why does inserting into the middle of an array cost O(n)?
  4. Why does checking whether an array contains a value cost O(n)? Pro
  5. What are the advantages and disadvantages of arrays? Pro
  6. Why do array indexes start at zero? Pro
  7. What happens when you access an array out of bounds? Pro
  8. When should you choose an array over a linked list, and why? Pro
  9. What is the cheapest way to delete from an array when order does not matter? Pro

Dynamic arrays and growth

How growable arrays manage length and capacity, why geometric growth gives amortized O(1) appends, and how shrinking and huge sizes go wrong.

9 questions

  1. What is the difference between a static array and a dynamic array?
  2. How does a dynamic array grow, and why is append amortized O(1)?
  3. What is the difference between a dynamic array's length and its capacity? Pro
  4. How does the growth factor of a dynamic array trade memory for copy work? Pro
  5. Why does a dynamic array rarely shrink its capacity when elements are removed? Pro
  6. How would you design a growable array that guarantees amortized O(1) appends? Pro
  7. What starts to break in a dynamic array as it nears a billion elements? Pro
  8. How does memory fragmentation affect allocating one large contiguous array? Pro
  9. How do you shrink a dynamic array without causing repeated resize thrashing? Pro

String immutability and building

Why strings are immutable, why concatenating in a loop is quadratic, and how string builders and ropes make building and editing text cheap.

5 questions

  1. What is a string, and why are strings immutable in many languages?
  2. Why is building a string by repeated concatenation in a loop slow? Pro
  3. Why does appending to a string create a whole new string? Pro
  4. Why use a string builder instead of repeated string concatenation? Pro
  5. When is a rope better than a contiguous string for large editable text? Pro

Hash table fundamentals

What hash maps and sets are for, how insert, lookup and delete work, and how keys are matched through equality and the hashCode contract.

10 questions

  1. What is a hash table and what problem does it solve?
  2. Why are hash table lookups considered O(1) on average?
  3. What is the difference between a hash set and a hash map?
  4. How do you insert, look up, and delete entries in a hash map? Pro
  5. What are the advantages and disadvantages of using a hash table? Pro
  6. What are the applications of hashing? Pro
  7. How does a map tell apart two keys that land in the same bucket? Pro
  8. What goes wrong when you mutate a key after putting it in a map? Pro
  9. What is the hashCode and equals contract, and why does it matter? Pro
  10. How does a hash set remove duplicate values in roughly O(n)? Pro

Hash function design

What a hash function does, what makes one good, how bucket count and key length affect it, how likely collisions are, and how to resist hash flooding.

9 questions

  1. What is a hash function and how does it map keys to buckets? Pro
  2. What is hashing? Pro
  3. What is the difference between a hash function and a hash table? Pro
  4. Can you give a simple example of a hash function? Pro
  5. What properties separate a good hash function from a bad one? Pro
  6. How can attacker-chosen keys force worst-case behavior, and how do you defend against it? Pro
  7. When does hashing a long key dominate cost, and why cache its hash? Pro
  8. Should a hash table's bucket count be a power of two or a prime, and why? Pro
  9. How likely are 64-bit hash collisions, and what does the birthday bound say? Pro

Collision resolution

Why collisions happen and how chaining and open addressing handle them: probing schemes, clustering, tombstones, memory and cache tradeoffs, and full map design.

10 questions

  1. What is a hash collision and why do collisions happen?
  2. How does chaining resolve collisions in a hash table? Pro
  3. What is the difference between separate chaining and open addressing? Pro
  4. How does linear probing find and place an element? Pro
  5. What is primary clustering, and which collision scheme suffers from it? Pro
  6. How does memory overhead compare between chaining and open addressing? Pro
  7. What is the difference between linear probing, quadratic probing, and double hashing? Pro
  8. Why does deleting from an open-addressed table need tombstones? Pro
  9. How would you design a hash map from scratch, and what are the key decisions? Pro
  10. Why can open addressing beat chaining on modern cache hierarchies? Pro

Load factor and resizing

How load factor drives collisions and resizes, why resizing stays amortized O(1), when operations degrade to O(n), and how to resize without a latency spike.

8 questions

  1. What is the load factor of a hash table?
  2. When does a hash table decide to resize, and what triggers it? Pro
  3. Why is a resize still O(1) amortized despite copying every element? Pro
  4. Under what conditions do hash table operations degrade to O(n)? Pro
  5. How do you choose a load factor threshold, and why around 0.75? Pro
  6. How does incremental resizing avoid a latency spike during rehash? Pro
  7. Can you resize a hash table without rehashing every existing key? Pro
  8. How do probe length and memory trade off at very high load factors? Pro

Iteration order and ordered maps

Why hash map iteration order is unstable, what fail-fast iteration means, and when to use a linked hash map or a tree-based ordered map instead.

4 questions

  1. When you loop over a hash map, is the iteration order predictable? Pro
  2. When would you pick a tree-based ordered map over a hash map? Pro
  3. Why do hash maps iterate in an unstable order, and what makes iteration fail-fast? Pro
  4. How does a linked hash map preserve insertion order, and at what cost? Pro

String internals

How strings are stored and compared under the hood: byte lengths and encodings, terminators, shared substrings, interning, cached hashes, small-string optimization and copy-on-write.

8 questions

  1. Why can two strings of the same visible length have different byte lengths? Pro
  2. How can a substring share memory with its parent string, and what is the risk? Pro
  3. Why is comparing two strings for equality not always O(1)? Pro
  4. What is string interning, and when does it help or hurt? Pro
  5. Why is a string's hash code often cached after it is first computed? Pro
  6. What is a null-terminated string, and how does it differ from a length-prefixed one? Pro
  7. What is small-string optimization, and what tradeoff does it make? Pro
  8. What are the benefits and hazards of copy-on-write arrays and strings? Pro

Cache locality and concurrency

How memory layout affects cache performance for arrays, and what it takes to make arrays and hash maps safe and fast when many threads use them.

6 questions

  1. Why do arrays get better cache performance than node-based structures? Pro
  2. How is a two-dimensional array laid out in memory, and how does that affect traversal? Pro
  3. Why does an array of objects often scan slower than an array of values? Pro
  4. How can concurrent writes to adjacent array elements cause false sharing? Pro
  5. What does it take to make a dynamic array safe for concurrent access? Pro
  6. How do you make a hash map both safe and fast under heavy concurrency? Pro

Advanced and distributed hashing

Specialized schemes like Robin Hood, cuckoo and perfect hashing, probabilistic sketches like Bloom filters and HyperLogLog, and consistent hashing across servers.

7 questions

  1. What problem does Robin Hood hashing solve, and how does it work? Pro
  2. How does cuckoo hashing guarantee worst-case O(1) lookups? Pro
  3. Why is consistent hashing used to distribute keys across servers? Pro
  4. When is a minimal perfect hash worth building for a static key set? Pro
  5. When does a Bloom filter beat a hash set, and what do you give up? Pro
  6. How do you count distinct items at scale without storing every key? Pro
  7. How do you rebalance a sharded hash table when a node joins or leaves? Pro
Practice · Questions

All questions

Showing of 85
Beginner 26
01

What is an array and how is it stored in memory?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

An array is a fixed sequence of elements of the same type, laid out back to back in one contiguous block of memory. Because every element takes the same number of bytes, the array only needs to remember its starting address and its length.

The values sit next to each other in order, with no gaps and no pointers linking them. A five-element integer array is just five integers packed tightly, one after another.

Reading nearby elements is fast, since the CPU pulls in whole cache lines at once. The cost is rigidity. The block is one piece, so you cannot cheaply grow it in place when neighboring memory is already taken.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is the difference between a static array and a dynamic array?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A static array has a fixed size chosen when it is created, and that size never changes. A dynamic array can grow and shrink at runtime, resizing itself as you add or remove elements.

A dynamic array still stores its elements in one contiguous block. When that block fills up, the array allocates a larger one and copies the elements across. You get flexibility, and you pay for it with an occasional resize.

Use a static array when you know the count ahead of time and want zero overhead. Use a dynamic array, like a Python list or a Java ArrayList, when the size is unknown or keeps changing. Access stays O(1) for both. Only the growth behavior differs between them.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

How does a dynamic array grow, and why is append amortized O(1)?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

A dynamic array grows by moving to a bigger block whenever the current one fills up. It allocates the new block, copies every element over, and releases the old one. The new block is a constant factor larger, often 1.5 or 2 times. Java's ArrayList grows by half each time, and CPython's list by about an eighth.

That copy costs O(n), so a single resize is not cheap. But resizes get rarer as the array grows. With doubling, going from 8 to 16 to 32 slots means the gaps between resizes keep doubling.

Spread the total copy work across every append, and each one averages out to constant time. That is what amortized O(1) means. An individual append occasionally spikes, but the long-run cost per append stays flat. Appending a million items in a row stays fast overall.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

Why is accessing an array element by its index O(1)?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Indexing is a single arithmetic step, not a search. Because an array is a contiguous block of equal-size elements, the computer locates any element with one formula.

address = base_address + index * element_size

Give it the index and it computes the exact memory location directly. It never scans or walks through earlier elements first. Element 0 and element 999 take the same amount of work to reach.

This constant-time access holds no matter how large the array grows, which is why arrays back so many other structures. The one requirement is that every element be the same size, so the multiplication always gives the element's exact address.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

Why does inserting into the middle of an array cost O(n)?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

Inserting in the middle forces every later element to move. An array keeps its values packed with no gaps. Making room at position k means shifting everything from k onward one slot to the right.

If you insert near the front of a million-element array, you shift almost a million elements. That shifting is the O(n) cost, and it grows with how much sits after the insertion point.

Appending at the end avoids this, because nothing follows the last element. Deleting from the middle costs the same, because shifting later elements left closes the gap. When you need frequent middle inserts, an array is often the wrong tool.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What is a hash table and what problem does it solve?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

A hash table stores key-value pairs and lets you insert, look up or delete by key in O(1) average time. The problem it solves is slow lookup. Searching an unsorted array means checking every element, which is O(n).

An array finds an element in one step only when you know its index. A hash table computes that index from the key. A hash function turns the key into a bucket number, and a lookup recomputes it to jump straight there.

Python's dict and Java's HashMap are both hash tables.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

Why are hash table lookups considered O(1) on average?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

On average, a good hash function scatters keys evenly across all the buckets. That even spread means most buckets hold very few entries, so finding the right one takes a small, roughly constant number of steps.

Look up a key and the table computes its bucket in one step, then checks the handful of entries there. With a low load factor, that handful is close to one. There is no dependence on the total number of stored items.

The word average matters. If many keys collide into the same bucket, that bucket becomes a long chain and lookup slows down. Good hash functions and controlled load factors keep collisions rare, which is what keeps the everyday cost at O(1).

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

What is the difference between a hash set and a hash map?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A hash set stores only keys, while a hash map stores keys paired with values. Both hash each key to place and find entries fast. The difference is what each slot holds.

A set answers one question, whether a key is present. You add keys and later ask whether a key is in the collection. A map answers a richer question, which value goes with a given key.

seen.add("alice");       // set: membership only
ages.set("alice", 30);   // map: key -> value

Use a set when you only care about presence or uniqueness, like tracking which IDs you have already processed. Use a map when each key needs an attached value. Internally, a set is often a map whose values are placeholders.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

What is a hash collision and why do collisions happen?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A hash collision happens when two different keys land in the same bucket. It happens because a hash function squeezes a huge space of possible keys into a small, finite number of buckets.

There are far more possible keys than slots, so by the pigeonhole principle some keys must share a slot. Even a great hash function cannot avoid this. It can only make collisions rare and evenly spread. Poor functions make it worse by clustering keys together.

Collisions are normal, not a bug, so every hash table has a plan for them. Common approaches store the clashing entries in a small list per bucket, or probe for the next open slot. Handling them well is what keeps lookups near O(1) instead of degrading.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

10

What is a string, and why are strings immutable in many languages?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A string is an ordered sequence of characters, usually stored as bytes that encode text. In many languages it behaves like a read-only array of characters that you can index and iterate over.

Immutability means that once a string is created, its contents never change. Operations that look like edits, such as replacing a character, build a brand new string and leave the original untouched.

Languages make this choice for safety and speed. Immutable strings can be shared freely between threads with no locking, and their hash code can be computed once and reused. The tradeoff is that heavy in-place editing wastes work creating copies. That is why building text in a loop should use a string builder instead.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

11

What is the load factor of a hash table?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

The load factor is the ratio between the number of stored entries and the number of buckets. A table with 6 entries across 8 buckets sits at 0.75. It is a single number describing how crowded the table is.

As the load factor rises, more keys share buckets, so collisions and chain lengths grow. Lookups that were near constant start scanning longer chains. Implementations watch this number and resize once it crosses a set threshold.

A low load factor wastes memory on empty buckets. A high one wastes time on collisions. Resizing at the threshold keeps the load between those two extremes, so average operations stay near O(1).

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

12

How do you insert, look up, and delete entries in a hash map?

Part of Pro
13

What is a hash function and how does it map keys to buckets?

Part of Pro
14

Why does checking whether an array contains a value cost O(n)?

Part of Pro
15

Why is building a string by repeated concatenation in a loop slow?

Part of Pro
16

How does chaining resolve collisions in a hash table?

Part of Pro Visual
17

When you loop over a hash map, is the iteration order predictable?

Part of Pro Visual
18

Why does appending to a string create a whole new string?

Part of Pro
19

What are the advantages and disadvantages of arrays?

Part of Pro
20

What are the advantages and disadvantages of using a hash table?

Part of Pro
21

What is hashing?

Part of Pro
22

What is the difference between a hash function and a hash table?

Part of Pro
23

Can you give a simple example of a hash function?

Part of Pro
24

What are the applications of hashing?

Part of Pro
25

Why do array indexes start at zero?

Part of Pro
26

What happens when you access an array out of bounds?

Part of Pro
Intermediate 32
27

When should you choose an array over a linked list, and why?

Part of Pro
28

What is the difference between a dynamic array's length and its capacity?

Part of Pro Visual
29

How does the growth factor of a dynamic array trade memory for copy work?

Part of Pro
30

Why do arrays get better cache performance than node-based structures?

Part of Pro Visual
31

Why does a dynamic array rarely shrink its capacity when elements are removed?

Part of Pro
32

Why use a string builder instead of repeated string concatenation?

Part of Pro Visual
33

Why can two strings of the same visible length have different byte lengths?

Part of Pro Visual
34

How can a substring share memory with its parent string, and what is the risk?

Part of Pro Visual
35

How is a two-dimensional array laid out in memory, and how does that affect traversal?

Part of Pro Visual
36

What is the cheapest way to delete from an array when order does not matter?

Part of Pro
37

Why is comparing two strings for equality not always O(1)?

Part of Pro
38

What is the difference between separate chaining and open addressing?

Part of Pro Visual
39

How does linear probing find and place an element?

Part of Pro Visual
40

What is primary clustering, and which collision scheme suffers from it?

Part of Pro Visual
41

When does a hash table decide to resize, and what triggers it?

Part of Pro
42

Why is a resize still O(1) amortized despite copying every element?

Part of Pro
43

What properties separate a good hash function from a bad one?

Part of Pro
44

How does a map tell apart two keys that land in the same bucket?

Part of Pro
45

What goes wrong when you mutate a key after putting it in a map?

Part of Pro Visual
46

What is the hashCode and equals contract, and why does it matter?

Part of Pro Visual
47

Under what conditions do hash table operations degrade to O(n)?

Part of Pro
48

How do you choose a load factor threshold, and why around 0.75?

Part of Pro
49

How does memory overhead compare between chaining and open addressing?

Part of Pro
50

How does a hash set remove duplicate values in roughly O(n)?

Part of Pro
51

When would you pick a tree-based ordered map over a hash map?

Part of Pro
52

What is string interning, and when does it help or hurt?

Part of Pro
53

Why is a string's hash code often cached after it is first computed?

Part of Pro
54

What is the difference between linear probing, quadratic probing, and double hashing?

Part of Pro Visual
55

What is a null-terminated string, and how does it differ from a length-prefixed one?

Part of Pro
56

Why does deleting from an open-addressed table need tombstones?

Part of Pro Visual
57

Why do hash maps iterate in an unstable order, and what makes iteration fail-fast?

Part of Pro Visual
58

How does a linked hash map preserve insertion order, and at what cost?

Part of Pro Visual
Expert 27
59

How would you design a growable array that guarantees amortized O(1) appends?

Part of Pro
60

What starts to break in a dynamic array as it nears a billion elements?

Part of Pro
61

Why does an array of objects often scan slower than an array of values?

Part of Pro Visual
62

How does memory fragmentation affect allocating one large contiguous array?

Part of Pro Visual
63

What is small-string optimization, and what tradeoff does it make?

Part of Pro Visual
64

When is a rope better than a contiguous string for large editable text?

Part of Pro Visual
65

How do you shrink a dynamic array without causing repeated resize thrashing?

Part of Pro Visual
66

How can concurrent writes to adjacent array elements cause false sharing?

Part of Pro Visual
67

What does it take to make a dynamic array safe for concurrent access?

Part of Pro Visual
68

What are the benefits and hazards of copy-on-write arrays and strings?

Part of Pro Visual
69

How would you design a hash map from scratch, and what are the key decisions?

Part of Pro
70

What problem does Robin Hood hashing solve, and how does it work?

Part of Pro Visual
71

How does cuckoo hashing guarantee worst-case O(1) lookups?

Part of Pro Visual
72

Why is consistent hashing used to distribute keys across servers?

Part of Pro Visual
73

How can attacker-chosen keys force worst-case behavior, and how do you defend against it?

Part of Pro
74

How does incremental resizing avoid a latency spike during rehash?

Part of Pro Visual
75

How do you make a hash map both safe and fast under heavy concurrency?

Part of Pro
76

Can you resize a hash table without rehashing every existing key?

Part of Pro Visual
77

When is a minimal perfect hash worth building for a static key set?

Part of Pro
78

When does a Bloom filter beat a hash set, and what do you give up?

Part of Pro Visual
79

How do you count distinct items at scale without storing every key?

Part of Pro Visual
80

When does hashing a long key dominate cost, and why cache its hash?

Part of Pro
81

Should a hash table's bucket count be a power of two or a prime, and why?

Part of Pro
82

How do probe length and memory trade off at very high load factors?

Part of Pro
83

Why can open addressing beat chaining on modern cache hierarchies?

Part of Pro
84

How likely are 64-bit hash collisions, and what does the birthday bound say?

Part of Pro
85

How do you rebalance a sharded hash table when a node joins or leaves?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Arrays, Strings & Hash Tables? Send them this set.
Quick recap

Arrays, Strings & Hash Tables in pictures.

A quick recap of Arrays, Strings & Hash Tables in 33 short animated pictures, one idea at a time. About 8 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.

Pro The first chapter is free to play. The other 29 pictures come with Pro.

Get Pro · $10/mo
Pro · $10/mo

74 of 85 Arrays, Strings & Hash Tables answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git