The 5 Data Structures That Will Dominate Your Next Technical Interview
If you’re preparing for interviews at companies like Mercado Libre, Nubank, Rappi, Globant, or looking for remote roles at US startups, there’s something you need to know: 70% of technical questions are solved with just 5 data structures.
It’s not about memorizing definitions. It’s about thinking in structures, not syntax.
In this first part of our series, we’re going to master the five structures that appear over and over in technical interviews — with practical examples and the typical questions they’ll ask you.
1. Array — The Foundation of Everything
An array is a contiguous block of memory that stores elements of the same type. Each element has an index that allows direct access in constant time.
Why is it so fast?
The magic is in the formula:
Address = Base Address + (Index Ă— Element Size)
There’s no traversal needed. The exact position in memory is calculated instantly.
When to use it
- You need instant access by index
- Your collection size is fixed or changes little
- Memory locality matters (frequent iterations)
Complexity
| Operation | Time |
|---|---|
| Access by index | O(1) |
| Search | O(n) |
| Insertion at end | O(1)* |
| Insertion in middle | O(n) |
| Deletion | O(n) |
*O(1) amortized if there’s capacity; O(n) if resizing is required.
Typical interview question
“Given an array of integers and a target, find two numbers that sum to the target.”
Tip: The optimal solution doesn’t use arrays alone — it uses a HashMap. This leads us to…
2. HashMap — Your Best Friend in Interviews
A HashMap stores key-value pairs using a hash function. It transforms any key into an array index, giving average O(1) access.
How it works internally
- The key passes through a hash function
- The hash is converted to an index in the internal array
- If two keys generate the same index (collision), they’re chained in a list
// Conceptual structure
"Maria" → hash("Maria") → index 3 → [("Maria", 28)]
"Pedro" → hash("Pedro") → index 7 → [("Pedro", 34)]
"Ana" → hash("Ana") → index 3 → [("Maria", 28), ("Ana", 25)] // collision
When to use it
- You need fast lookups by key
- You’re counting element frequencies
- You need to detect duplicates
- You want to map relationships (user → data, product → price)
Complexity
| Operation | Average | Worst case |
|---|---|---|
| Search | O(1) | O(n) |
| Insertion | O(1) | O(n) |
| Deletion | O(1) | O(n) |
The worst case occurs with many collisions (bad hash function or adversarial data).
Typical interview question
“Find the first non-repeating character in a string.”
Solution: A HashMap to count frequencies, then a second pass to find the first with count = 1.
3. Stack — LIFO and Why It Matters
A Stack operates under the principle LIFO: Last In, First Out. The last element that enters is the first one that exits.
Think of a stack of plates: you can only take the one on top.
Fundamental operations
push(4) → [4]
push(11) → [4, 11]
push(6) → [4, 11, 6]
peek() → 6 (just look, don't remove)
pop() → [4, 11] (removes the 6)
When to use it
- You need LIFO order
- You’re implementing undo/redo functionality
- You’re parsing expressions (balanced parentheses, postfix notation)
- You’re handling recursive calls (the system’s call stack is literally a stack)
Complexity
| Operation | Time |
|---|---|
| push | O(1) |
| pop | O(1) |
| peek | O(1) |
| search | O(n) |
Typical interview question
“Given a string with parentheses, brackets, and braces, determine if it’s balanced.”
Strategy: Push on each opening, pop and compare on each closing. If the stack is empty at the end and all closings matched, it’s balanced.
4. Queue — FIFO for BFS and Processing
A Queue operates under the principle FIFO: First In, First Out. The first element that enters is the first one that exits.
Think of a line at a bank: the first to arrive is the first to be served.
Fundamental operations
enqueue(7) → [7]
enqueue(3) → [7, 3]
dequeue() → [3] (7 exits)
enqueue(8) → [3, 8]
front() → 3 (next to exit)
When to use it
- Processing in order of arrival
- BFS (Breadth-First Search) in graphs and trees
- Task and message queue systems
- Data buffers (streaming, I/O)
Complexity
| Operation | Time |
|---|---|
| enqueue | O(1) |
| dequeue | O(1) |
| front | O(1) |
| search | O(n) |
Typical interview question
“Given a binary tree, return its values level by level.”
Strategy: BFS with a queue. Enqueue the root, and in each iteration process all nodes at the current level while enqueueing their children.
5. Linked List — Flexibility vs. Arrays
A Linked List stores elements in nodes scattered throughout memory, connected via pointers.
Structure of a node
class Node {
int data;
Node next;
Node(int data) {
this.data = data;
this.next = null;
}
}
Main types
- Singly Linked List: Each node points only to the next
- Doubly Linked List: Each node points to both previous and next
- Circular: The last node points back to the first
When to use it
- Frequent insertions/deletions at the start or in the middle
- You don’t know the final size beforehand
- You’re implementing stacks, queues, or LRU caches
- Memory is fragmented
Complexity
| Operation | Time |
|---|---|
| Access by index | O(n) |
| Insertion at start | O(1) |
| Insertion at end | O(1)* |
| Deletion (given the node) | O(1) |
| Search | O(n) |
*O(1) if you maintain a reference to the tail; O(n) if you must traverse.
Typical interview question
“Detect if a linked list has a cycle.”
Strategy: Floyd’s algorithm (tortoise and hare). Two pointers: one advances by one, the other by two. If they meet, there’s a cycle.
Quick Comparison
| Structure | Best for | Avoid when |
|---|---|---|
| Array | Access by index, iteration | Frequent insertions in middle |
| HashMap | Key lookup, counting | You need order |
| Stack | LIFO, parsing, recursion | You need random access |
| Queue | FIFO, BFS, processing | You need random access |
| Linked List | Dynamic insertions | Frequent access by index |
Coming Next: Part 2
In the second part we’ll cover the structures that make you stand out in senior interviews:
- Trees — The foundation of hierarchy
- Binary Search Tree — Ordered search
- Heaps — Priority queues and Top-K
- Graphs — Modeling complex relationships
Which of these structures has given you the most trouble in interviews? Share your experience in the comments.
***This article is part of the “Data Structures for Technical Interviews” series on yoDEV. Follow us so you don’t miss the next installment.




