Skip to content
Tech Interview Prep home
Technical interview guide

Arrays & Hashing

Contiguous storage, O(1) average-case lookups via hash maps, and the frequency-counting patterns they enable.

Read
42 min
Practice MCQs
25
Interview QA
25
Edition
v6
Editorial status
Reviewed

Scope: Language-neutral, with operation costs cited from CPython 3.14, the C++ standard containers, and java.util as of Java 21.

Interview QA

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

QA-1

Explain the contiguous-array cost model and how it changes a production decision.

QA-2

How would you reason about amortised append and growth factors in a system you own?

QA-3

Walk through the hash-table average versus worst case, including where engineers most often get it wrong.

QA-4

What does the hash and equality contract guarantee, and what does it deliberately leave open?

QA-5

Describe load factor and resizing and the evidence you would collect before relying on it.

QA-6

A teammate proposes a design that hinges on chaining versus open addressing. How do you evaluate it?

QA-7

Where does sets as membership structures matter, and where is it irrelevant?

QA-8

Teach frequency counting to an engineer who has only seen it as a rule of thumb.

QA-9

If last week's incident involved the complement lookup pattern, what would you write in the report?

QA-10

How would you test a claim that the system depends on prefix sums?

QA-11

What would you measure before treating prefix sums with a hash map as settled?

QA-12

How does in-place array rearrangement change if the workload grows by two orders of magnitude?

QA-13

You insert an object into a HashMap and then mutate one of the fields the hash was computed from. What breaks, what does it look like at runtime, and how do the language runtimes you use defend against it?

QA-14

When would you refuse a design because of grouping by a canonical key?

QA-15

How would you explain hash keys built from sequences without using the usual slogan?

QA-16

What failure would you inject to check a team's understanding of insertion-ordered maps?

QA-17

Walk me through what happens inside a hash table when two keys collide: chaining vs open addressing, what the load factor controls, when and why the table resizes, and what the worst-case lookup cost is and how a good hash function avoids it.

QA-18

Given a list of strings, encode it into a single string and decode it back exactly. Why does joining with a delimiter fail, when is length-prefixing sufficient, and what do empty strings and embedded delimiters do to each scheme?

QA-19

Given an unsorted array of integers, find the length of the longest run of consecutive values in O(n). Why do we only expand from elements whose predecessor is absent, and what does sorting cost instead?

QA-20

What trade-off does hashing for constant-time deletion force that a junior answer usually skips?

QA-21

How do you map a 2D matrix to a 1D array using row-major vs. column-major indexing, and how does row-major layout affect CPU cache locality during traversal?

QA-22

What is the smallest experiment that would change your mind about encoding state in the array itself?

QA-23

How does cache locality and the constant factor interact with rollback, and where do people ignore that?

QA-24

How does dynamic resizing and rehashing work in a hash map, and how does load factor tuning balance lookup latency against memory overhead?

QA-25

When is a direct-indexed array strictly superior to a hash map for key-value lookups, and where does that choice collapse?