Learning Data Structures for Technical Interviews Without Memorising Answers
A common way to prepare for technical interviews is to work through a long list of practice questions and hope the real interview repeats one of them. It is exhausting and fragile.
Silicon Lab Team24 Aug 20265 min read
A common way to prepare for technical interviews is to work through a long list of practice questions and hope the real interview repeats one of them. It is exhausting and fragile. Change a detail of the problem and a memorised answer stops working. A better approach is to understand a small set of data structures and problem-solving patterns well enough to apply them to questions you have never seen.
Why memorising fails
The point of an interview question is not whether you have seen it before. An interviewer wants to see how you reason: how you clarify the question, find a first solution, spot its weaknesses and improve it. A memorised answer skips all of that. Worse, if you recognise a question but misremember the solution, you have nothing to fall back on.
Understanding lasts. If you know why a hash map makes a lookup fast, you will think of using one whenever a problem involves checking whether you have seen something before.
First, know the structures
Before practising problems, make sure you can explain each of these core structures: what it is, what it is good at and what it costs.
- Arrays and strings — fast access by position; inserting in the middle is slow.
- Hash maps and sets — fast lookup, insertion and removal by key; no order.
- Stacks — last in, first out; useful for undoing, matching brackets and depth-first processes.
- Queues — first in, first out; useful for processing in order and breadth-first search.
- Linked lists — cheap insertion and removal once you are at the right node; slow to search.
- Trees, especially binary search trees — ordered data with efficient search when balanced.
- Heaps — quick access to the smallest or largest item; useful for "top k" problems and scheduling.
- Graphs — relationships between things: networks, maps, dependencies.
For each one, learn the time cost of its main operations in Big-O notation. You should be able to say, without looking it up, why searching an unsorted array is slower than looking up a key in a hash map.
Then, learn the patterns
A handful of recurring patterns sit underneath a wide range of interview problems. Learn to recognise the signals:
- Hashing for lookup. Signal: "have I seen this before?" or "find a pair that…". Store what you have seen in a set or map.
- Two pointers. Signal: a sorted array or a string where you compare elements from both ends, or a fast and slow pointer moving through a list.
- Sliding window. Signal: "the longest or shortest continuous section that…". Grow and shrink a window instead of checking every section.
- Binary search. Signal: sorted data, or any question where you can test whether an answer is too big or too small.
- Recursion and backtracking. Signal: "all possible combinations", "every arrangement", or a problem that breaks into smaller copies of itself.
- Breadth-first and depth-first search. Signal: grids, trees, networks, "shortest path" or "is there a route".
- Dynamic programming. Signal: overlapping subproblems, such as counting the number of ways to do something. Learn this last, once the others are comfortable.
When you practise, the goal is not to solve the problem but to ask: which pattern is this, and what gave it away?
How to practise a single problem
Use the same steps every time so the process becomes a habit you can rely on under pressure:
- Restate the problem in your own words and ask what the inputs and outputs are.
- Work through a small example by hand, including an edge case: an empty input, a single element, duplicates.
- Find a brute-force solution first, even if it is slow. Say its time cost.
- Identify the bottleneck. What is the slow step? Which pattern removes it?
- Write the improved solution clearly, with sensible names.
- Test it against your examples and edge cases by tracing the code.
- State the final time and space cost.
If you are stuck for too long, read a solution — but then close it and write your own version from scratch the next day.
How to check you understand, not just remember
- Explain it aloud. If you cannot explain why the solution works, you have memorised it.
- Solve a variant. Change one condition in the problem and solve it again.
- Come back later. Re-solve the problem after a few days without notes.
- Switch languages. Writing the solution in a second language forces you to think about the logic rather than recall lines of code.
- Teach it. Explaining a pattern to a classmate is one of the fastest ways to find gaps in your own understanding.
A sustainable weekly routine
Consistency matters more than long sessions. A simple weekly structure:
- One session on a structure or pattern — read, take notes, implement the structure yourself.
- Several short practice sessions — a few problems using that pattern, following the seven steps above.
- One review session — revisit problems from earlier weeks without notes.
- One mock interview — solve a problem aloud with a friend or on your own with a timer, explaining as you go.
Keep a simple log: the problem, the pattern, what you got stuck on and what you learned. Before an interview, reading this log is far more useful than attempting new problems.
During the interview
- Ask clarifying questions before writing code.
- Think aloud so the interviewer can follow your reasoning.
- Start with a simple working solution, then improve it.
- Test your code with an example before saying you are finished.
- If you get stuck, say what you are considering. Interviewers can only help if they know where you are.
The takeaway
A problem list is endless; the set of core structures and patterns is not. Learn what each structure is good at, practise recognising patterns, follow a consistent process for each problem, and test your understanding by explaining and varying solutions. That preparation holds up when the interview question is one you have never seen.